@@ -119,14 +119,7 @@ impl<T> Dijkstra<T> {
119119
120120 for start in start_nodes {
121121 for end in & end_nodes {
122- Self :: visit (
123- start,
124- * end,
125- & mut Vec :: new ( ) ,
126- & mut VecDeque :: new ( ) ,
127- & mut paths,
128- come_from,
129- ) ;
122+ Self :: visit ( start, * end, & mut VecDeque :: new ( ) , & mut paths, come_from) ;
130123 }
131124 }
132125
@@ -136,32 +129,28 @@ impl<T> Dijkstra<T> {
136129 fn visit (
137130 end : T ,
138131 current : T ,
139- visited : & mut Vec < T > ,
140- path : & mut VecDeque < T > ,
132+ current_path : & mut VecDeque < T > ,
141133 paths : & mut Vec < VecDeque < T > > ,
142134 come_from : & HashMap < T , Vec < T > > ,
143135 ) where
144136 T : Hash + Eq + PartialEq + Ord + Debug + Copy ,
145137 {
146- visited. push ( current) ;
147- path. push_front ( current) ;
138+ current_path. push_front ( current) ;
148139
149140 if end == current {
150- paths. push ( path. clone ( ) ) ;
151- path. pop_front ( ) ;
152- visited. pop ( ) ;
141+ paths. push ( current_path. clone ( ) ) ;
142+ current_path. pop_front ( ) ;
153143
154144 return ;
155145 }
156146
157147 for p in come_from. get ( & current) . unwrap_or ( & Vec :: new ( ) ) {
158- if !visited . contains ( p) {
159- Self :: visit ( end, * p, visited , path , paths, come_from) ;
148+ if !current_path . contains ( p) {
149+ Self :: visit ( end, * p, current_path , paths, come_from) ;
160150 }
161151 }
162152
163- path. pop_front ( ) ;
164- visited. pop ( ) ;
153+ current_path. pop_front ( ) ;
165154 }
166155}
167156
0 commit comments