Skip to content

Commit

Permalink
catch errors in sample network
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed May 14, 2024
1 parent 03db918 commit 4414149
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Integer call() throws Exception {

RandomizedTravelTime tt = new RandomizedTravelTime(rnd);

LeastCostPathCalculator router = createRandomizedRouter(network, tt);
LeastCostPathCalculator router = createRandomizedRouter(cityNetwork, tt);

sampleCityRoutes(cityNetwork, router, tt, rnd);

Expand Down Expand Up @@ -223,9 +223,16 @@ private void sampleCityRoutes(Network network, LeastCostPathCalculator router, R

Link to = NetworkUtils.getNearestLink(network, dest);

// Links could be on the very edge so that nodes are outside the network
if (to == null || !network.getNodes().containsKey(link.getFromNode().getId()) ||
!network.getNodes().containsKey(to.getToNode().getId())) {
i--;
continue;
}

LeastCostPathCalculator.Path path = router.calcLeastCostPath(link.getFromNode(), to.getToNode(), 0, null, null);

if (path.nodes.size() < 2) {
if (path == null || path.nodes.size() < 2) {
i--;
continue;
}
Expand Down

0 comments on commit 4414149

Please sign in to comment.