diff --git a/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraphBuilder.java b/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraphBuilder.java index 724343da24d..d610a0c63b3 100644 --- a/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraphBuilder.java +++ b/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraphBuilder.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -120,7 +121,10 @@ private SpeedyGraph buildWithTurnRestrictions(Network network) { for (Node node : network.getNodes().values()) { this.nodes[node.getId().index()] = node; } - for (Link link : network.getLinks().values()) { + List> linkIds = new ArrayList<>(network.getLinks().keySet()); + Collections.sort(linkIds); + for (Id linkId : linkIds) { + Link link = network.getLinks().get(linkId); if (context.replacedLinks.get(link.getId()) == null) { addLink(link); } @@ -310,7 +314,10 @@ private SpeedyGraph buildWithoutTurnRestrictions(Network network) { for (Node node : network.getNodes().values()) { this.nodes[node.getId().index()] = node; } - for (Link link : network.getLinks().values()) { + List> linkIds = new ArrayList<>(network.getLinks().keySet()); + Collections.sort(linkIds); + for (Id linkId : linkIds) { + Link link = network.getLinks().get(linkId); addLink(link); }