diff --git a/platform/core-impl/src/com/intellij/util/graph/impl/KShortestPathsFinder.java b/platform/core-impl/src/com/intellij/util/graph/impl/KShortestPathsFinder.java index a73cf7c5dc03..5afd08821461 100644 --- a/platform/core-impl/src/com/intellij/util/graph/impl/KShortestPathsFinder.java +++ b/platform/core-impl/src/com/intellij/util/graph/impl/KShortestPathsFinder.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.graph.impl; import com.intellij.openapi.diagnostic.Logger; @@ -7,6 +7,7 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.util.containers.FList; import com.intellij.util.containers.MultiMap; import com.intellij.util.graph.Graph; +import com.intellij.util.graph.InboundSemiGraph; import gnu.trove.TObjectIntHashMap; import org.jetbrains.annotations.NotNull; @@ -20,7 +21,7 @@ import java.util.*; */ public class KShortestPathsFinder { private static final Logger LOG = Logger.getInstance("#com.intellij.util.graph.impl.KShortestPathsFinder"); - private final Graph myGraph; + private final InboundSemiGraph myGraph; private final Node myStart; private final Node myFinish; private final ProgressIndicator myProgressIndicator; @@ -30,11 +31,18 @@ public class KShortestPathsFinder { private Map> myOutRoots; private Map> myHeaps; - public KShortestPathsFinder(@NotNull Graph graph, @NotNull Node start, @NotNull Node finish, @NotNull ProgressIndicator progressIndicator) { + public KShortestPathsFinder(@NotNull Graph graph, @NotNull Node start, @NotNull Node finish, @NotNull ProgressIndicator progress) { + this(((InboundSemiGraph)graph), start, finish, progress); + } + + public KShortestPathsFinder(@NotNull InboundSemiGraph graph, + @NotNull Node start, + @NotNull Node finish, + @NotNull ProgressIndicator progress) { myGraph = graph; myStart = start; myFinish = finish; - myProgressIndicator = progressIndicator; + myProgressIndicator = progress; } private void computeDistancesToTarget() { @@ -309,4 +317,4 @@ public class KShortestPathsFinder { return new HeapNode<>(this); } } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/util/graph/impl/ShortestPathFinder.java b/platform/core-impl/src/com/intellij/util/graph/impl/ShortestPathFinder.java index 322b1e9e8479..c873b535d088 100644 --- a/platform/core-impl/src/com/intellij/util/graph/impl/ShortestPathFinder.java +++ b/platform/core-impl/src/com/intellij/util/graph/impl/ShortestPathFinder.java @@ -1,7 +1,8 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.graph.impl; import com.intellij.util.graph.Graph; +import com.intellij.util.graph.InboundSemiGraph; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -10,12 +11,15 @@ import java.util.*; * @author nik */ public class ShortestPathFinder { - private final Graph myGraph; + private final InboundSemiGraph myGraph; public ShortestPathFinder(Graph graph) { myGraph = graph; } + public ShortestPathFinder(InboundSemiGraph graph) { + myGraph = graph; + } @Nullable public List findPath(Node start, Node finish) { @@ -44,6 +48,7 @@ public class ShortestPathFinder { if (!found) { return null; } + List path = new ArrayList<>(); Node current = start; while (!current.equals(finish)) { @@ -53,4 +58,4 @@ public class ShortestPathFinder { path.add(finish); return path; } -} +} \ No newline at end of file