@@ -109,7 +109,6 @@ List<AlternativeInfo> calcAlternatives(final int s, final int t) {
109
109
PotentialAlternativeInfo potentialAlternativeInfo = new PotentialAlternativeInfo ();
110
110
potentialAlternativeInfo .v = fromSPTEntry .adjNode ;
111
111
potentialAlternativeInfo .edgeIn = getIncomingEdge (fromSPTEntry );
112
- potentialAlternativeInfo .edgeOut = getIncomingEdge (toSPTEntry );
113
112
potentialAlternativeInfo .weight = 2 * (fromSPTEntry .getWeightOfVisitedPath () + toSPTEntry .getWeightOfVisitedPath ()) + preliminaryShare ;
114
113
potentialAlternativeInfos .add (potentialAlternativeInfo );
115
114
return true ;
@@ -120,17 +119,18 @@ List<AlternativeInfo> calcAlternatives(final int s, final int t) {
120
119
for (PotentialAlternativeInfo potentialAlternativeInfo : potentialAlternativeInfos ) {
121
120
int v = potentialAlternativeInfo .v ;
122
121
int tailSv = potentialAlternativeInfo .edgeIn ;
123
- int headVt = potentialAlternativeInfo .edgeOut ;
124
122
125
123
// Okay, now we want the s -> v -> t shortest via-path, so we route s -> v and v -> t
126
124
// and glue them together.
127
125
DijkstraBidirectionEdgeCHNoSOD svRouter = new DijkstraBidirectionEdgeCHNoSOD (graph );
128
- final Path svPath = svRouter .calcPath (s , v , ANY_EDGE , tailSv );
126
+ final Path suvPath = svRouter .calcPath (s , v , ANY_EDGE , tailSv );
129
127
extraVisitedNodes += svRouter .getVisitedNodes ();
130
128
129
+ int u = graph .getBaseGraph ().getEdgeIteratorState (tailSv , v ).getBaseNode ();
130
+
131
131
DijkstraBidirectionEdgeCHNoSOD vtRouter = new DijkstraBidirectionEdgeCHNoSOD (graph );
132
- final Path vtPath = vtRouter .calcPath (v , t , headVt , ANY_EDGE );
133
- Path path = concat (graph .getBaseGraph (), svPath , vtPath );
132
+ final Path uvtPath = vtRouter .calcPath (u , t , tailSv , ANY_EDGE );
133
+ Path path = concat (graph .getBaseGraph (), suvPath , uvtPath );
134
134
extraVisitedNodes += vtRouter .getVisitedNodes ();
135
135
136
136
double sharedDistanceWithShortest = sharedDistanceWithShortest (path );
@@ -148,7 +148,7 @@ List<AlternativeInfo> calcAlternatives(final int s, final int t) {
148
148
// This is the final test we need: Discard paths that are not "locally shortest" around v.
149
149
// So move a couple of nodes to the left and right from v on our path,
150
150
// route, and check if v is on the shortest path.
151
- final IntIndexedContainer svNodes = svPath .calcNodes ();
151
+ final IntIndexedContainer svNodes = suvPath .calcNodes ();
152
152
int vIndex = svNodes .size () - 1 ;
153
153
if (!tTest (path , vIndex ))
154
154
continue ;
@@ -236,21 +236,21 @@ private EdgeIteratorState getNextNodeTMetersAway(Path path, int vIndex, double T
236
236
return edges .get (i - 1 );
237
237
}
238
238
239
- private static Path concat (Graph graph , Path svPath , Path vtPath ) {
240
- assert svPath .isFound ();
241
- assert vtPath .isFound ();
239
+ private static Path concat (Graph graph , Path suvPath , Path uvtPath ) {
240
+ assert suvPath .isFound ();
241
+ assert uvtPath .isFound ();
242
242
Path path = new Path (graph );
243
- path .setFromNode (svPath .calcNodes ().get (0 ));
244
- for (EdgeIteratorState edge : svPath .calcEdges ()) {
245
- path .addEdge (edge .getEdge ());
246
- }
247
- for (EdgeIteratorState edge : vtPath .calcEdges ()) {
243
+ path .setFromNode (suvPath .calcNodes ().get (0 ));
244
+ for (EdgeIteratorState edge : suvPath .calcEdges ()) {
248
245
path .addEdge (edge .getEdge ());
249
246
}
250
- path .setEndNode (vtPath .getEndNode ());
251
- path .setWeight (svPath .getWeight () + vtPath .getWeight ());
252
- path .setDistance (svPath .getDistance () + vtPath .getDistance ());
253
- path .addTime (svPath .time + vtPath .time );
247
+ Iterator <EdgeIteratorState > uvtPathI = uvtPath .calcEdges ().iterator ();
248
+ uvtPathI .next (); // skip u-v edge
249
+ uvtPathI .forEachRemaining (edge -> path .addEdge (edge .getEdge ()));
250
+ path .setEndNode (uvtPath .getEndNode ());
251
+ path .setWeight (suvPath .getWeight () + uvtPath .getWeight ());
252
+ path .setDistance (suvPath .getDistance () + uvtPath .getDistance ());
253
+ path .addTime (suvPath .time + uvtPath .time );
254
254
path .setFound (true );
255
255
return path ;
256
256
}
@@ -271,7 +271,6 @@ public List<Path> calcPaths(int from, int to) {
271
271
public static class PotentialAlternativeInfo {
272
272
public int v ;
273
273
public int edgeIn ;
274
- public int edgeOut ;
275
274
double weight ;
276
275
}
277
276
0 commit comments