Пример #1
0
  public static void main(String[] args) {
    System.out.println("Test 2");
    Network net3 = new Network();

    net3.addConnection(1, 2);
    net3.addConnection(3, 1);
    net3.addConnection(2, 4);
    System.out.println(net3.addConnection(4, 3));
    System.out.println(net3.addConnection(3, 3));
    System.out.println(net3.addConnection(3, 3));
    net3.addConnection(100, 4);
    net3.addConnection(3, 100);
    net3.addConnection(2, 5);
    net3.addConnection(5, 6);
    net3.addConnection(6, 7);

    net3.findTree();

    Collection switches3 = net3.getSwitches();
    Iterator iter3 = switches3.iterator();
    while (iter3.hasNext()) {
      Switch y = (Switch) iter3.next();
      System.out.println("Switch: Root, Parent, Hops to Root");
      String output = "  " + y.getMAC() + ":      ";
      output = output + y.getRoot().getMAC() + "      ";
      output = output + y.getParent().getMAC() + "         ";
      output = output + y.getDistance();
      System.out.println(output);
    }
  }
Пример #2
0
 public void dispatch(Switch sw) {
   super.dispatch(sw);
   sw.onSQLBlock(this);
 }