File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -394,18 +394,22 @@ export function Graph(serialized?: Serialized) {
394394 function shortestPaths ( source : NodeId , destination : NodeId ) {
395395 let path = shortestPath ( source , destination ) ;
396396 const paths = [ path ] ,
397- removedEdges : any = [ ] ,
397+ removedEdges : { u : NodeId ; v : NodeId ; weight : EdgeWeight } [ ] = [ ] ,
398398 weight = path . weight ;
399399 while ( weight ) {
400- [
401- [ path [ 0 ] , path [ 1 ] ] ,
402- [ path [ 1 ] , path [ 0 ] ] ,
403- ] . forEach ( ( [ u , v ] ) => {
404- if ( hasEdge ( u , v ) ) {
405- removedEdges . push ( { u, v, weight : getEdgeWeight ( u , v ) } ) ;
406- removeEdge ( u , v ) ;
407- }
408- } ) ;
400+ const u = path [ 0 ] ;
401+ const v = path [ 1 ] ;
402+
403+ if ( hasEdge ( u , v ) ) {
404+ removedEdges . push ( { u, v, weight : getEdgeWeight ( u , v ) } ) ;
405+ removeEdge ( u , v ) ;
406+ }
407+
408+ if ( hasEdge ( v , u ) ) {
409+ removedEdges . push ( { u : v , v : u , weight : getEdgeWeight ( v , u ) } ) ;
410+ removeEdge ( v , u ) ;
411+ }
412+
409413 try {
410414 path = shortestPath ( source , destination ) ;
411415 if ( ! path . weight || weight < path . weight ) break ;
You can’t perform that action at this time.
0 commit comments