@@ -119,14 +119,7 @@ impl<T> Dijkstra<T> {
119
119
120
120
for start in start_nodes {
121
121
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) ;
130
123
}
131
124
}
132
125
@@ -136,32 +129,28 @@ impl<T> Dijkstra<T> {
136
129
fn visit (
137
130
end : T ,
138
131
current : T ,
139
- visited : & mut Vec < T > ,
140
- path : & mut VecDeque < T > ,
132
+ current_path : & mut VecDeque < T > ,
141
133
paths : & mut Vec < VecDeque < T > > ,
142
134
come_from : & HashMap < T , Vec < T > > ,
143
135
) where
144
136
T : Hash + Eq + PartialEq + Ord + Debug + Copy ,
145
137
{
146
- visited. push ( current) ;
147
- path. push_front ( current) ;
138
+ current_path. push_front ( current) ;
148
139
149
140
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 ( ) ;
153
143
154
144
return ;
155
145
}
156
146
157
147
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) ;
160
150
}
161
151
}
162
152
163
- path. pop_front ( ) ;
164
- visited. pop ( ) ;
153
+ current_path. pop_front ( ) ;
165
154
}
166
155
}
167
156
0 commit comments