Graph:...al::BFS(3pm)

✨ Graph::Traversal::BFS β€” bestie edition πŸ’–

okay so this is Graph::Traversal::BFS, from the User Contributed Perl Documentation section of the manual (it's a 3pm page, iykyk πŸ’…). Sit down, grab a strawberry πŸ“, we're doing breadth-first traversal.


🌸 NAME 🌸

Graph::Traversal::BFS β€” breadth-first traversal of graphs. that's it, that's the whole vibe. we go wide before we go deep πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

use Graph;
my $g = Graph->new;
$g->add_edge(...);
use Graph::Traversal::BFS;
my $b = Graph::Traversal::BFS->new($g, %opt);
$b->bfs; # Do the traversal.

literally the whole plot: make a Graph, add some edges, pull in the traversal class, build a $b with your graph and your %opt, then call $b->bfs and boom πŸ’₯ β€” that's your traversal, done, slay.


πŸ’œ DESCRIPTION πŸ’œ

With this class one can traverse a Graph in breadth-first order. so like, all the neighbors first, then their neighbors, level by level, like ripples in a pond 🌊 or like when a rumor spreads through the group chat β€” everyone at the same distance hears it at the same time, no cap.

The callback parameters %opt are explained over in Graph::Traversal. go read that one, bestie, it's the whole lore πŸ‘‘

πŸ”₯ Methods πŸ”₯

The following methods are available β€” yes, it's a short list, quality over quantity, main character energy only:

  • bfs β€” Traverse the graph in breadth-first order. Returns all vertices traversed in post-order. so you get the whole lineup back at the end 🫢

🌈 SEE ALSO 🌈

  • Graph::Traversal
  • Graph::Traversal::DFS
  • Graph

go check those out, they're the supporting cast and honestly they ate ✨


and that's the page, bestie!! this one's from perl v5.40.1, dated 2025-03-28 β€” love that for us πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from