Graphle 1.0.0
A C++20 header-only graph library
Loading...
Searching...
No Matches
depth_first_search.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <common.hpp>
4#include <graph/graph.hpp>
9
10
11namespace graphle::search {
29 template <
30 graph_ref G,
31 search_visitor_ref<G> V,
32 store::storage_provider_ref<store::storage_type::VECTOR, vertex_of<G>> PV
33 = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>,
34 store::storage_provider_ref<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>> PS
35 = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>
36 > requires (
37 edge_list_graph<G> ||
38 out_edges_graph<G> ||
39 (non_directed_graph<G> && in_edges_graph<G>)
40 ) constexpr inline bool depth_first_search(
41 G&& graph,
42 vertex_of<G> root,
43 V&& visitor,
46 ) {
47 return detail::search<store::storage_type::VECTOR>(
48 graph,
49 root,
50 visitor,
51 [] (auto& stack, auto elem) { stack.push_back(elem); },
52 [] (auto& stack) { return util::take_back(stack); },
53 GRAPHLE_FWD(stack_provider),
54 GRAPHLE_FWD(set_provider)
55 );
56 }
57}
#define GRAPHLE_FWD(...)
Definition: common.hpp:14
typename std::remove_cvref_t< G >::vertex_hash_t vertex_hash_of
Definition: graph.hpp:99
typename std::remove_cvref_t< G >::vertex_compare_t vertex_compare_of
Definition: graph.hpp:95
typename std::remove_cvref_t< G >::vertex_type vertex_of
Definition: graph.hpp:91
constexpr bool depth_first_search(G &&graph, vertex_of< G > root, V &&visitor, PV &&stack_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), PS &&set_provider=store::get_default_storage_provider< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > >())
constexpr auto get_default_storage_provider(void)
constexpr rng::range_value_t< C > take_back(C &container)