rubenada commented on a change in pull request #2007:
URL: https://github.com/apache/calcite/pull/2007#discussion_r436546022
##########
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:
(minor) Maybe adding a unit test for the same node scenario?
`assertEquals(0, frozenGraph.getShortestDistance("B", "B"));`
----------------------------------------------------------------
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:
[email protected]