diff --git a/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraph.java b/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraph.java index fbb2896a408..b1b9edf5f1e 100644 --- a/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraph.java +++ b/matsim/src/main/java/org/matsim/core/router/speedy/SpeedyGraph.java @@ -5,7 +5,10 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.List; /** * Implements a highly optimized data structure for representing a MATSim network. Optimized to use as little memory as possible, and thus to fit as much memory as possible into CPU caches for high @@ -70,7 +73,11 @@ public SpeedyGraph(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); } }