Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
lazy_graph_traversal_example.cc File Reference

Lazy graph BFS/DFS with coroutines (graph-traverse-generators.H). More...

#include <iostream>
#include <string>
#include <graph-traverse-generators.H>
#include <graph-traverse.H>
#include <print_rule.H>
#include <tpl_graph.H>
Include dependency graph for lazy_graph_traversal_example.cc:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Lazy graph BFS/DFS with coroutines (graph-traverse-generators.H).

Overview

Graph_Traverse (graph-traverse.H) already supports early termination: its visitor callback returns bool, and false stops the walk. What Graph_Traverse_BFS_Generator/Graph_Traverse_DFS_Generator (graph-traverse-generators.H) add is ergonomics and composability: the exact same algorithm, driven by a plain range-for with break instead of a callback that has to remember to return false, and naturally chainable with other lazy code.

This example runs the same "find a node, stop as soon as you do" search both ways on a small social-network graph, to make the code-shape difference concrete.

See also
bfs_dfs_example.C The eager callback-based version of this walk.
Author
Leandro Rabindranath Leon

Definition in file lazy_graph_traversal_example.cc.

Function Documentation

◆ main()

int main ( void  )