@ Override public Path extract ( ) { if ( sptEntry == null || edgeTo == null ) return this ; if ( sptEntry . adjNode != edgeTo . adjNode ) throw new IllegalStateException ( "Locations of the 'to'- and 'from'-Edge have to be the same. " + toString ( ) + ", fromEntry:" + sptEntry + ", toEntry:" + edgeTo ) ; extractSW . start ( ) ; if ( switchFromAndToSPTEntry ) { SPTEntry ee = sptEntry ; sptEntry = edgeTo ; edgeTo = ee ; } SPTEntry currEdge = sptEntry ; boolean nextEdgeValid = EdgeIterator . Edge . isValid ( currEdge . edge ) ; int nextEdge ; while ( nextEdgeValid ) { // the reverse search needs the next edge nextEdgeValid = EdgeIterator . Edge . isValid ( currEdge . parent . edge ) ; nextEdge = nextEdgeValid ? currEdge . parent . edge : EdgeIterator . NO_EDGE ; processEdge ( currEdge . edge , currEdge . adjNode , nextEdge ) ; currEdge = currEdge . parent ; } setFromNode ( currEdge . adjNode ) ; reverseOrder ( ) ; currEdge = edgeTo ; int prevEdge = EdgeIterator . Edge . isValid ( sptEntry . edge ) ? sptEntry . edge : EdgeIterator . NO_EDGE ; int tmpEdge = currEdge . edge ; while ( EdgeIterator . Edge . isValid ( tmpEdge ) ) { currEdge = currEdge . parent ; processEdge ( tmpEdge , currEdge . adjNode , prevEdge ) ; prevEdge = tmpEdge ; tmpEdge = currEdge . edge ; } setEndNode ( currEdge . adjNode ) ; extractSW . stop ( ) ; return setFound ( true ) ; }
Extracts path from two shortest - path - tree