Graphle 1.0.0
A C++20 header-only graph library
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
Search methods

Classes

class  graphle::search::search_visitor< Derived, Graph >
 

Enumerations

enum class  graphle::search::visitor_result { graphle::search::visitor_result::CONTINUE , graphle::search::visitor_result::STOP_TREE , graphle::search::visitor_result::STOP_SEARCH }
 
enum class  graphle::search::nonlocal_visitor_result { graphle::search::nonlocal_visitor_result::CONTINUE , graphle::search::nonlocal_visitor_result::STOP_SEARCH }
 

Functions

template<graph_ref G, search_visitor_ref< G > V, store::storage_provider_ref< store::storage_type::DEQUE, vertex_of< G > > PQ = store::default_provided_t<store::storage_type::DEQUE, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::search::breadth_first_search (G &&graph, vertex_of< G > root, V &&visitor, PQ &&deque_provider=store::get_default_storage_provider< store::storage_type::DEQUE, 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 > >())
 
template<graph_ref G, search_visitor_ref< G > V, store::storage_provider_ref< store::storage_type::VECTOR, vertex_of< G > > PV = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::search::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 > >())
 
template<store::storage_type ST, graph_ref G, search::search_visitor_ref< G > V, typename EmplacePP , typename TakePP , store::storage_provider_ref< ST, vertex_of< G > > PP = store::default_provided_t<ST, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::detail::search (G &&graph, vertex_of< G > root, V &&visitor, EmplacePP &&emplace, TakePP &&take, PP &&pending_provider=store::get_default_storage_provider< ST, 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 > >())
 

Detailed Description

Enumeration Type Documentation

◆ nonlocal_visitor_result

Equivalent to visitor_result, but not linked to any specific location in the graph, so lacking the option STOP_TREE.

Enumerator
CONTINUE 

Continue the search normally.

STOP_SEARCH 

Stop the search and return early.

Definition at line 49 of file visitor.hpp.

◆ visitor_result

Indicates to a search algorithm what to do after invoking a visitor method.

Enumerator
CONTINUE 

Continue the search normally.

STOP_TREE 

Do not visit any vertices by reaching them from the current vertex, but continue the search otherwise.

STOP_SEARCH 

Stop the search and return early.

Definition at line 35 of file visitor.hpp.

Function Documentation

◆ breadth_first_search()

template<graph_ref G, search_visitor_ref< G > V, store::storage_provider_ref< store::storage_type::DEQUE, vertex_of< G > > PQ = store::default_provided_t<store::storage_type::DEQUE, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::search::breadth_first_search ( G &&  graph,
vertex_of< G >  root,
V &&  visitor,
PQ &&  deque_provider = store::get_default_storage_provider<store::storage_type::DEQUE, 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>>() 
)
inlineconstexpr

Performs a breadth first search (BFS) on the given graph, invoking the appropriate callbacks on the provided visitor.

Parameters
graphA graphle::graph to visit.
rootThe root vertex to start the depth first search from.
visitorA visitor implementing the graphle::search_visitor interface.
deque_providerAn optional storage-provider which can provide a deque-like type for the algorithm to use.
set_providerAn optional storage-provider which can provide a unordered-set-like type for the algorithm to use.
Returns
True if the algorithm finished normally or false if the visitor caused the algorithm to return early.
Graph Requirements:

Definition at line 40 of file breadth_first_search.hpp.

◆ depth_first_search()

template<graph_ref G, search_visitor_ref< G > V, store::storage_provider_ref< store::storage_type::VECTOR, vertex_of< G > > PV = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::search::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>>() 
)
inlineconstexpr

Performs a depth first search (DFS) on the given graph, invoking the appropriate callbacks on the provided visitor.

Parameters
graphA graphle::graph to visit.
rootThe root vertex to start the depth first search from.
visitorA visitor implementing the graphle::search_visitor interface.
stack_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use.
set_providerAn optional storage-provider which can provide a unordered-set-like type for the algorithm to use.
Returns
True if the algorithm finished normally or false if the visitor caused the algorithm to return early.
Graph Requirements:

Definition at line 40 of file depth_first_search.hpp.

◆ search()

template<store::storage_type ST, graph_ref G, search::search_visitor_ref< G > V, typename EmplacePP , typename TakePP , store::storage_provider_ref< ST, vertex_of< G > > PP = store::default_provided_t<ST, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_SET, vertex_of< G >, vertex_hash_of< G >, vertex_compare_of< G > > PS = store::default_provided_t<store::storage_type::UNORDERED_SET, vertex_of<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( edge_list_graph<G> || out_edges_graph<G> || (non_directed_graph<G> && in_edges_graph<G>) )
constexpr bool graphle::detail::search ( G &&  graph,
vertex_of< G >  root,
V &&  visitor,
EmplacePP &&  emplace,
TakePP &&  take,
PP &&  pending_provider = store::get_default_storage_provider<ST, 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>>() 
)
inlineconstexpr

Common implementation for the BFS and DFS search algorithms, since their implementation is the same, just using a queue vs. a stack to keep track of the pending elements.

Template Parameters
STThe storage type used for the pending vertex list (DEQUE for BFS, VECTOR for DFS).
Parameters
graphA graphle::graph to visit.
rootThe root vertex to start the depth first search from.
visitorA visitor implementing the graphle::search_visitor interface.
emplaceAn object invocable as emplace(pending, element) to emplace the given element into the pending vertex list.
takeAn object invocable as take(pending) to take an element from the pending vertex list.
pending_providerAn optional storage-provider which can provide storage of type ST for the algorithm to use.
set_providerAn optional storage-provider which can provide a unordered-set-like type for the algorithm to use.
Returns
True if the algorithm finished normally or false if the visitor caused the algorithm to return early.
Graph Requirements:

Definition at line 53 of file search_impl.hpp.