Beispiel #1
0
  public int testFindEdge() {
    int foo = 0;

    // for each pair of nodes (n1, n2) find the edge between n1 and n2
    long start = System.currentTimeMillis();
    for (String id1 : nodeIds) {
      Node n1 = g.getNode(id1);
      for (String id2 : nodeIds) {
        Edge e = n1.getEdgeBetween(id2);
        if (e != null && e.hasAttribute("foo")) foo++;
      }
    }
    end = System.currentTimeMillis();
    measureValues.put(Measures.EDGE_BETWEEN, end - start);

    // for each pair of nodes (n1, n2) find the edge from n1 to n2
    start = System.currentTimeMillis();
    for (String id1 : nodeIds) {
      Node n1 = g.getNode(id1);
      for (String id2 : nodeIds) {
        Edge e = n1.getEdgeToward(id2);
        if (e != null && e.hasAttribute("foo")) foo++;
      }
    }
    end = System.currentTimeMillis();
    measureValues.put(Measures.EDGE_TOWARD, end - start);

    // for each pair of nodes (n1, n2) find the edge from n2 to n1
    start = System.currentTimeMillis();
    for (String id1 : nodeIds) {
      Node n1 = g.getNode(id1);
      for (String id2 : nodeIds) {
        Edge e = n1.getEdgeFrom(id2);
        if (e != null && e.hasAttribute("foo")) foo++;
      }
    }
    end = System.currentTimeMillis();
    measureValues.put(Measures.EDGE_FROM, end - start);

    return foo;
  }