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/16 14:49:56 UTC

[GitHub] [calcite] rubenada commented on a change in pull request #2027: [CALCITE-4049] Improve the implementation of the shortest-path algorithm

rubenada commented on a change in pull request #2027:
URL: https://github.com/apache/calcite/pull/2027#discussion_r440911347



##########
File path: core/src/main/java/org/apache/calcite/util/graph/Graphs.java
##########
@@ -56,42 +54,40 @@ public int size() {
   public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable(
       DirectedGraph<V, E> graph) {
     DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph;
-    Map<Pair<V, V>, List<V>> shortestPaths = new HashMap<>();
+    Map<Pair<V, V>, int[]> shortestDistances = new HashMap<>();
     for (DefaultDirectedGraph.VertexInfo<V, E> arc
         : graph1.vertexMap.values()) {
       for (E edge : arc.outEdges) {
         final V source = graph1.source(edge);
         final V target = graph1.target(edge);
-        shortestPaths.put(Pair.of(source, target),
-            ImmutableList.of(source, target));
+        shortestDistances.put(Pair.of(source, target), new int[] {1});
       }
     }
     while (true) {
       // Take a copy of the map's keys to avoid
       // ConcurrentModificationExceptions.
       final List<Pair<V, V>> previous =
-          ImmutableList.copyOf(shortestPaths.keySet());
-      int changeCount = 0;
+          ImmutableList.copyOf(shortestDistances.keySet());
+      boolean changeCount = false;

Review comment:
       minor thing: now that this variable is a `boolean`, maybe it should be renamed (`changeCount` -> `change` ?)




----------------------------------------------------------------
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