@@ -210,16 +210,16 @@ impl<N: Debug, E: Debug> Graph<N, E> {
210
210
. map ( |( idx, e) | ( EdgeIndex ( idx) , e) )
211
211
}
212
212
213
- pub fn each_node < ' a > ( & ' a self , mut f : impl FnMut ( NodeIndex , & ' a Node < N > ) -> bool ) -> bool
214
- {
213
+ pub fn each_node < ' a > ( & ' a self , mut f : impl FnMut ( NodeIndex , & ' a Node < N > ) -> bool ) -> bool {
215
214
//! Iterates over all edges defined in the graph.
216
- self . enumerated_nodes ( ) . all ( |( node_idx, node) | f ( node_idx, node) )
215
+ self . enumerated_nodes ( )
216
+ . all ( |( node_idx, node) | f ( node_idx, node) )
217
217
}
218
218
219
- pub fn each_edge < ' a > ( & ' a self , mut f : impl FnMut ( EdgeIndex , & ' a Edge < E > ) -> bool ) -> bool
220
- {
219
+ pub fn each_edge < ' a > ( & ' a self , mut f : impl FnMut ( EdgeIndex , & ' a Edge < E > ) -> bool ) -> bool {
221
220
//! Iterates over all edges defined in the graph
222
- self . enumerated_edges ( ) . all ( |( edge_idx, edge) | f ( edge_idx, edge) )
221
+ self . enumerated_edges ( )
222
+ . all ( |( edge_idx, edge) | f ( edge_idx, edge) )
223
223
}
224
224
225
225
pub fn outgoing_edges ( & self , source : NodeIndex ) -> AdjacentEdges < N , E > {
@@ -253,18 +253,19 @@ impl<N: Debug, E: Debug> Graph<N, E> {
253
253
self . incoming_edges ( target) . sources ( )
254
254
}
255
255
256
- pub fn depth_traverse < ' a > ( & ' a self ,
257
- start : NodeIndex ,
258
- direction : Direction )
259
- -> DepthFirstTraversal < ' a , N , E > {
256
+ pub fn depth_traverse < ' a > (
257
+ & ' a self ,
258
+ start : NodeIndex ,
259
+ direction : Direction ,
260
+ ) -> DepthFirstTraversal < ' a , N , E > {
260
261
DepthFirstTraversal :: with_start_node ( self , start, direction)
261
262
}
262
263
263
- pub fn nodes_in_postorder < ' a > ( & ' a self ,
264
- direction : Direction ,
265
- entry_node : NodeIndex )
266
- -> Vec < NodeIndex >
267
- {
264
+ pub fn nodes_in_postorder < ' a > (
265
+ & ' a self ,
266
+ direction : Direction ,
267
+ entry_node : NodeIndex ,
268
+ ) -> Vec < NodeIndex > {
268
269
let mut visited = BitVector :: new ( self . len_nodes ( ) ) ;
269
270
let mut stack = vec ! [ ] ;
270
271
let mut result = Vec :: with_capacity ( self . len_nodes ( ) ) ;
@@ -274,7 +275,8 @@ impl<N: Debug, E: Debug> Graph<N, E> {
274
275
}
275
276
} ;
276
277
277
- for node in Some ( entry_node) . into_iter ( )
278
+ for node in Some ( entry_node)
279
+ . into_iter ( )
278
280
. chain ( self . enumerated_nodes ( ) . map ( |( node, _) | node) )
279
281
{
280
282
push_node ( & mut stack, node) ;
@@ -300,8 +302,9 @@ impl<N: Debug, E: Debug> Graph<N, E> {
300
302
// # Iterators
301
303
302
304
pub struct AdjacentEdges < ' g , N , E >
303
- where N : ' g ,
304
- E : ' g
305
+ where
306
+ N : ' g ,
307
+ E : ' g ,
305
308
{
306
309
graph : & ' g Graph < N , E > ,
307
310
direction : Direction ,
@@ -334,8 +337,9 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
334
337
}
335
338
336
339
pub struct DepthFirstTraversal < ' g , N , E >
337
- where N : ' g ,
338
- E : ' g
340
+ where
341
+ N : ' g ,
342
+ E : ' g ,
339
343
{
340
344
graph : & ' g Graph < N , E > ,
341
345
stack : Vec < NodeIndex > ,
@@ -344,10 +348,11 @@ pub struct DepthFirstTraversal<'g, N, E>
344
348
}
345
349
346
350
impl < ' g , N : Debug , E : Debug > DepthFirstTraversal < ' g , N , E > {
347
- pub fn with_start_node ( graph : & ' g Graph < N , E > ,
348
- start_node : NodeIndex ,
349
- direction : Direction )
350
- -> Self {
351
+ pub fn with_start_node (
352
+ graph : & ' g Graph < N , E > ,
353
+ start_node : NodeIndex ,
354
+ direction : Direction ,
355
+ ) -> Self {
351
356
let mut visited = BitVector :: new ( graph. len_nodes ( ) ) ;
352
357
visited. insert ( start_node. node_id ( ) ) ;
353
358
DepthFirstTraversal {
0 commit comments