@@ -6,24 +6,22 @@ use crate::vertex_id::VertexId;
66use hashbrown:: HashSet ;
77#[ cfg( not( feature = "no_std" ) ) ]
88use std:: collections:: VecDeque ;
9- #[ cfg( not( feature = "no_std" ) ) ]
10- use std:: sync:: Arc ;
119
1210#[ cfg( feature = "no_std" ) ]
1311extern crate alloc;
1412#[ cfg( feature = "no_std" ) ]
15- use alloc:: { collections:: vec_deque:: VecDeque , sync :: Arc } ;
13+ use alloc:: { collections:: vec_deque:: VecDeque } ;
1614
1715#[ cfg( feature = "no_std" ) ]
1816use alloc:: vec:: Vec ;
1917
2018#[ derive( Debug ) ]
2119/// Breadth-First Iterator
2220pub struct Bfs < ' a , T > {
23- queue : VecDeque < Arc < VertexId > > ,
24- current_ptr : Option < Arc < VertexId > > ,
25- visited_set : HashSet < Arc < VertexId > > ,
26- roots_stack : Vec < Arc < VertexId > > ,
21+ queue : VecDeque < VertexId > ,
22+ current_ptr : Option < VertexId > ,
23+ visited_set : HashSet < VertexId > ,
24+ roots_stack : Vec < VertexId > ,
2725 iterable : & ' a Graph < T > ,
2826}
2927
@@ -32,7 +30,7 @@ impl<'a, T> Bfs<'a, T> {
3230 let mut roots_stack = Vec :: with_capacity ( graph. roots_count ( ) ) ;
3331
3432 for v in graph. roots ( ) {
35- roots_stack. push ( Arc :: from ( * v ) ) ;
33+ roots_stack. push ( v . clone ( ) ) ;
3634 }
3735
3836 let current_ptr = roots_stack. pop ( ) ;
@@ -66,8 +64,8 @@ impl<'a, T> Iterator for Bfs<'a, T> {
6664 // and check their visited status.
6765 for n in self . iterable . out_neighbors ( current_ptr. as_ref ( ) ) {
6866 if !self . visited_set . contains ( n) {
69- self . visited_set . insert ( Arc :: from ( * n ) ) ;
70- self . queue . push_back ( Arc :: from ( * n ) ) ;
67+ self . visited_set . insert ( n . clone ( ) ) ;
68+ self . queue . push_back ( n . clone ( ) ) ;
7169
7270 return self . iterable . fetch_id_ref ( n) ;
7371 }
0 commit comments