You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* executes closure on each {@link Vertex} in breadth first order. See {@link #breadthFirstTraversal} for details.
569
+
* @param closure
570
+
*/
571
+
voideachBfs(Closureclosure) {
572
+
eachBfs(null, closure)
573
+
}
574
+
575
+
/**
576
+
* executes closure on each {@link Vertex} in breadth first order starting at the given root {@link Vertex}. See {@link #breadthFirstTraversal} for details.
577
+
* @param root
578
+
* @param closure
579
+
*/
580
+
voideachBfs(Stringroot, Closureclosure) {
581
+
breadthFirstTraversal {
582
+
delegate.root = root
583
+
visit { vertex->
584
+
closure(vertex)
585
+
returnnull
586
+
}
587
+
}
588
+
}
589
+
590
+
/**
591
+
* Executes closure on each {@link Vertex} in breadth first order. If the closure returns true the {@link Vertex} is
592
+
* returned.
593
+
* @param closure closure to execute on each {@link Vertex}
594
+
* @return first {@link Vertex} where closure returns true
595
+
*/
596
+
VertexfindBfs(Closureclosure) {
597
+
findBfs(null, closure)
598
+
}
599
+
600
+
/**
601
+
* Executes closure on each {@link Vertex} in breadth first order starting at root. If the closure returns true the
602
+
* {@link Vertex} is returned.
603
+
* @param root where to start breadth first traversal
604
+
* @param closure closure to execute on each {@link Vertex}
605
+
* @return first {@link Vertex} where closure returns true
606
+
*/
607
+
VertexfindBfs(Stringroot, Closureclosure) {
608
+
Vertex result =null
609
+
breadthFirstTraversal {
610
+
delegate.root = root
611
+
visit { vertex->
612
+
if (closure(vertex)) {
613
+
result = vertex
614
+
returnTraversal.STOP
615
+
}
616
+
}
617
+
}
618
+
result
619
+
}
620
+
621
+
/**
622
+
* Executes closure on each vertex in breadth first order. object is the initial value passed to the closure. Each returned
623
+
* value from the closure is passed to the next call.
624
+
* @param object
625
+
* @param closure
626
+
* @return object returned from the final call to closure.
627
+
*/
628
+
definjectBfs(Objectobject, Closureclosure) {
629
+
injectBfs(null, object, closure)
630
+
}
631
+
632
+
/**
633
+
* Executes closure on each vertex in breadth first order starting at root. object is the initial value passed to the closure. Each returned
634
+
* value from the closure is passed to the next call.
635
+
* @param root
636
+
* @param object
637
+
* @param closure
638
+
* @return object returned from the final call to closure.
0 commit comments