Ejemplo n.º 1
0
 public void testDirectedDegree(Graph<String, String> graph) {
   graph.createNode("a");
   graph.createNode("b");
   graph.createNode("c");
   graph.createNode("d");
   assertEquals(0, graph.getNodeDegree("a"));
   graph.connect("a", "-", "b");
   assertEquals(1, graph.getNodeDegree("a"));
   graph.connect("b", "-", "c");
   assertEquals(1, graph.getNodeDegree("a"));
   graph.connect("a", "-", "c");
   assertEquals(2, graph.getNodeDegree("a"));
   graph.connect("d", "-", "a");
   assertEquals(3, graph.getNodeDegree("a"));
 }
Ejemplo n.º 2
0
 public void testEdgeAnnotations() {
   Graph<String, String> graph = new LinkedUndirectedGraph<String, String>();
   graph.createNode("1");
   graph.createNode("2");
   graph.createNode("3");
   graph.connect("1", "a", "2");
   graph.connect("2", "b", "3");
   GraphEdge<String, String> a = graph.getEdges("1", "2").get(0);
   GraphEdge<String, String> b = graph.getEdges("2", "3").get(0);
   checkAnnotations(graph, a, b);
 }