33 #ifdef OGDF_INCLUDE_CGAL
46 template<
typename Graph = OGDFGraphWrapper,
typename Flags = datastructure::TimestampFlags>
49 using Node =
typename Graph::Node;
50 using Edge =
typename Graph::Edge;
53 std::queue<Node> queue;
56 static void settle_nothing(Node) {
59 static bool expand_all(Node,
typename Graph::Edge) {
return true; }
61 static void traverse_nothing(Node, Edge) {
65 BFS(
const Graph& graph_) : graph(graph_), visited(graph.max_node_index() + 1) {
69 template<
typename Range,
typename FSettle,
typename FExpandEdge,
typename FTraverseEdge,
70 typename InitVisit,
typename AlreadyVisited,
typename MarkVisited>
71 void traverse2(Range& sources, InitVisit&& init_visit, AlreadyVisited&& already_visited,
72 MarkVisited&& mark_visited, FSettle&& settle_node = settle_nothing,
73 FExpandEdge&& expand_edge = expand_all, FTraverseEdge&& traverse_edge = traverse_nothing) {
75 for (
auto v : sources) {
79 unsigned int iterations = 0;
80 while (!queue.empty()) {
83 Node current_node = queue.front();
85 settle_node(current_node);
86 for (
const Edge&
edge : graph.edges(current_node)) {
88 if (expand_edge(current_node,
edge) && !already_visited(opposite)) {
89 traverse_edge(current_node,
edge);
91 mark_visited(opposite);
97 template<
typename Range,
typename FSettle,
typename FExpandEdge,
typename FTraverseEdge>
98 void traverse(Range sources, FSettle&& settle_node = settle_nothing,
99 FExpandEdge&& expand_edge = expand_all, FTraverseEdge&& traverse_edge = traverse_nothing) {
101 sources, [&]() { visited.clear(); },
102 [&](
Node u) {
return visited.is_set(u->index()); },
103 [&](
Node u) { visited.set(u->index()); }, settle_node, expand_edge, traverse_edge);
106 template<
typename Range,
typename FSettle>
107 void traverse(Range& source, FSettle&& settle_node) {
108 traverse(source, settle_node, expand_all, traverse_nothing);
111 template<
typename FSettle,
typename FExpandEdge,
typename FTraverseEdge>
112 void traverse(Node& source, FSettle&& settle_node = settle_nothing,
113 FExpandEdge&& expand_edge = expand_all, FTraverseEdge&& traverse_edge = traverse_nothing) {
114 std::vector<Node> sources = {source};
115 traverse(sources, settle_node, expand_edge, traverse_edge);