Ejemplo n.º 1
0
  public void testAddRemove() {
    // add 10000 new nodes
    start = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) g.addNode("__newnode__" + i);
    end = System.currentTimeMillis();
    measureValues.put(Measures.ADD_NODE, end - start);

    // for each new node n, add 100 edges between n and old nodes
    start = System.currentTimeMillis();
    int current = 0;
    int edgeId = 0;
    for (int i = 0; i < 10000; i++) {
      String id = "__newnode__" + i;
      for (int j = 0; j < 100; j++) {
        g.addEdge("__newedge__" + edgeId, id, nodeIds.get(current));
        edgeId++;
        current++;
        if (current == nodeIds.size()) current = 0;
      }
    }
    end = System.currentTimeMillis();
    measureValues.put(Measures.ADD_EDGE, end - start);

    // remove all the new nodes (and new edges)
    start = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) g.removeNode("__newnode__" + i);
    end = System.currentTimeMillis();
    measureValues.put(Measures.REMOVE_NODE, end - start);

    // remove 10000 edges
    start = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) g.removeEdge(edgeIds.get(i));
    end = System.currentTimeMillis();
    measureValues.put(Measures.REMOVE_EDGE, end - start);
  }
  // For removing Node From Graph
  public void RemoveNodeAndEdgesFromGraph(String IP, boolean IsSwitch) {
    String temp = "EndHost";

    if (IsSwitch) {
      temp = "OpenVSwitch";
    }

    network_graph.removeNode(temp + " [" + IP + "]");
  }