Skip to content

Commit

Permalink
make Speedy Builder more deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kohl committed May 13, 2024
1 parent 9e3b33c commit 9cf21d4
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Id<Link>> linkIds = new ArrayList<>(network.getLinks().keySet());
Collections.sort(linkIds);
for (Id<Link> linkId : linkIds) {
Link link = network.getLinks().get(linkId);
if (context.replacedLinks.get(link.getId()) == null) {
addLink(link);
}
Expand Down Expand Up @@ -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<Id<Link>> linkIds = new ArrayList<>(network.getLinks().keySet());
Collections.sort(linkIds);
for (Id<Link> linkId : linkIds) {
Link link = network.getLinks().get(linkId);
addLink(link);
}

Expand Down

0 comments on commit 9cf21d4

Please sign in to comment.