@@ -613,33 +613,22 @@ where
613
613
614
614
// Calculate `TopologicalSortVertexInfo::num_predecessors`
615
615
let mut num_vertices_remaining = 0 ;
616
- {
617
- let mut it_vertices = graph. vertices ( ) ;
618
- while let Some ( v) = it_vertices. next ( ) {
619
- temp_vertex_info[ & v] = TopologicalSortVertexInfo {
620
- num_predecessors : 0 ,
621
- } ;
622
- num_vertices_remaining += 1 ;
623
- }
616
+ for v in graph. vertices ( ) {
617
+ temp_vertex_info[ & v] = TopologicalSortVertexInfo {
618
+ num_predecessors : 0 ,
619
+ } ;
620
+ num_vertices_remaining += 1 ;
624
621
}
625
- {
626
- let mut it_vertices = graph. vertices ( ) ;
627
- while let Some ( v) = it_vertices. next ( ) {
628
- let mut it_successors = graph. successors ( & v) ;
629
- while let Some ( successor) = it_successors. next ( ) {
630
- temp_vertex_info[ & successor] . num_predecessors += 1 ;
631
- }
622
+ for v in graph. vertices ( ) {
623
+ for successor in graph. successors ( & v) {
624
+ temp_vertex_info[ & successor] . num_predecessors += 1 ;
632
625
}
633
626
}
634
627
635
628
// Push predecessor-less vertices to `temp_ready_vertex_queue`
636
- {
637
- let mut it_vertices = graph. vertices ( ) ;
638
- while let Some ( v) = it_vertices. next ( ) {
639
- if temp_vertex_info[ & v] . num_predecessors == 0 {
640
- temp_ready_vertex_queue
641
- . heap_push ( v, ReadyVertexQueueBinaryHeapCtx { vertex_ord_lt } ) ;
642
- }
629
+ for v in graph. vertices ( ) {
630
+ if temp_vertex_info[ & v] . num_predecessors == 0 {
631
+ temp_ready_vertex_queue. heap_push ( v, ReadyVertexQueueBinaryHeapCtx { vertex_ord_lt } ) ;
643
632
}
644
633
}
645
634
@@ -648,8 +637,7 @@ where
648
637
{
649
638
// Remove `v` from the graph, and push the now-predecessor-less
650
639
// vertices to `temp_ready_vertex_queue`
651
- let mut it_successors = graph. successors ( & v) ;
652
- while let Some ( successor) = it_successors. next ( ) {
640
+ for successor in graph. successors ( & v) {
653
641
temp_vertex_info[ & successor] . num_predecessors -= 1 ;
654
642
if temp_vertex_info[ & successor] . num_predecessors == 0 {
655
643
temp_ready_vertex_queue
0 commit comments