You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/06/08 08:59:03 UTC

[GitHub] [calcite] liyafan82 commented on a change in pull request #2007: [CALCITE-4049] Reduce the time complexity of getting shortest distances

liyafan82 commented on a change in pull request #2007:
URL: https://github.com/apache/calcite/pull/2007#discussion_r436550032



##########
File path: core/src/test/java/org/apache/calcite/util/graph/DirectedGraphTest.java
##########
@@ -215,6 +215,34 @@
     assertEquals("[D, E]", frozenGraph.getShortestPath("D", "E").toString());
   }
 
+  @Test void testDistances() {
+    //       B -> C
+    //      /      \
+    //     A        E
+    //      \      /
+    //       D -->
+    final DefaultDirectedGraph<String, DefaultEdge> graph =
+        DefaultDirectedGraph.create();
+    graph.addVertex("A");
+    graph.addVertex("B");
+    graph.addVertex("C");
+    graph.addVertex("D");
+    graph.addVertex("E");
+    graph.addVertex("F");
+    graph.addEdge("A", "B");
+    graph.addEdge("B", "C");
+    graph.addEdge("A", "D");
+    graph.addEdge("D", "E");
+    graph.addEdge("C", "E");
+    final Graphs.FrozenGraph<String, DefaultEdge> frozenGraph =
+        Graphs.makeImmutable(graph);
+    assertEquals(1, frozenGraph.getShortestDistance("A", "B"));

Review comment:
       Done. Thank you for the good suggestion. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org