Graphle 1.0.0
A C++20 header-only graph library
Loading...
Searching...
No Matches
Functions
Graph algorithms

Functions

template<directed_graph G, typename Target , 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::VECTOR, vertex_of< G > > PVM = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > > PM = store::default_provided_t<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( vertex_list_graph<G> && (edge_list_graph<G> || out_edges_graph<G>) && std::output_iterator<std::remove_cvref_t<Target>, typename std::remove_cvref_t<Target>::value_type> && std::output_iterator<typename std::remove_cvref_t<Target>::value_type, vertex_of<G>> )
constexpr void graphle::alg::strongly_connected_components (G &&graph, Target &&target, std::size_t min_size=0, PV &&stack_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), PVM &&min_stack_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), PM &&map_provider=store::get_default_storage_provider< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > >())
 
template<directed_graph G, store::storage_provider_ref< store::storage_type::VECTOR, vertex_of< G > > InnerPR = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::VECTOR, store::provided_storage_value_type< InnerPR > > OuterPR = store::default_provided_t<store::storage_type::VECTOR, store::provided_storage_value_type<InnerPR>>, 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::VECTOR, vertex_of< G > > PVM = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > > PM = store::default_provided_t<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( vertex_list_graph<G> && (edge_list_graph<G> || out_edges_graph<G>) )
constexpr decltype(auto) graphle::alg::strongly_connected_components (G &&graph, std::size_t min_size=0, GRAPHLE_MULTIPLE InnerPR &&inner_ret_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), OuterPR &&outer_ret_provider=store::get_default_storage_provider< store::storage_type::VECTOR, store::provided_storage_value_type< InnerPR > >(), PV &&stack_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), PVM &&min_stack_provider=store::get_default_storage_provider< store::storage_type::VECTOR, vertex_of< G > >(), PM &&map_provider=store::get_default_storage_provider< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > >())
 

Detailed Description

Function Documentation

◆ strongly_connected_components() [1/2]

template<directed_graph G, store::storage_provider_ref< store::storage_type::VECTOR, vertex_of< G > > InnerPR = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::VECTOR, store::provided_storage_value_type< InnerPR > > OuterPR = store::default_provided_t<store::storage_type::VECTOR, store::provided_storage_value_type<InnerPR>>, 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::VECTOR, vertex_of< G > > PVM = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > > PM = store::default_provided_t<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( vertex_list_graph<G> && (edge_list_graph<G> || out_edges_graph<G>) )
constexpr decltype(auto) graphle::alg::strongly_connected_components ( G &&  graph,
std::size_t  min_size = 0,
GRAPHLE_MULTIPLE InnerPR &&  inner_ret_provider = store::get_default_storage_provider<store::storage_type::VECTOR, vertex_of<G>>(),
OuterPR &&  outer_ret_provider = store::get_default_storage_provider<store::storage_type::VECTOR, store::provided_storage_value_type<InnerPR>>(),
PV &&  stack_provider = store::get_default_storage_provider<store::storage_type::VECTOR, vertex_of<G>>(),
PVM &&  min_stack_provider = store::get_default_storage_provider<store::storage_type::VECTOR, vertex_of<G>>(),
PM &&  map_provider = store::get_default_storage_provider<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>() 
)
inlineconstexpr

Finds all strongly connected components (cycles) in the given directed graph using Tarjan's algorithm (Tarjan, R. (1972). Depth-First Search and Linear Graph Algorithms. SIAM Journal on Computing, 1(2), 146–160. doi:10.1137/0201010). This non-recursive version of the algorithm is based on the implementation by Thomas Ahle: https://stackoverflow.com/a/62006383

This overload returns its data as a Vector<Vector<Vertex>> (See return type).

Parameters
graphA graphle::graph to find the strongly connected components of.
min_sizeStrongly connected components with a cycle length smaller than this value will be discarded. Typically, when e.g. searching for cyclic dependencies, you will want to discard all size-1 cycles, since these indicate vertices that do not have any dependencies at all.
inner_ret_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use. Used for the returned value (See return type).
outer_ret_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use. Used for the returned value (See return type).
stack_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use.
min_stack_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use.
map_providerAn optional storage-provider which can provide a unordered-map-like type for the algorithm to use.
Returns
Returns a VectorOuter<VectorInner<Vertex>>, where VectorOuter is the storage type provided by OuterPR (std::vector by default) where VectorInner is the storage type provided by InnerPR (std::vector by default) The value category of the returned value is equal to that of the outer_ret_provider, i.e. if outer_ret_provider() returns a reference, this function returns a reference also.
Graph Requirements:

Definition at line 224 of file strongly_connected_components.hpp.

◆ strongly_connected_components() [2/2]

template<directed_graph G, typename Target , 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::VECTOR, vertex_of< G > > PVM = store::default_provided_t<store::storage_type::VECTOR, vertex_of<G>>, store::storage_provider_ref< store::storage_type::UNORDERED_MAP, vertex_of< G >, detail::tarjan_vertex_data< G >, vertex_hash_of< G >, vertex_compare_of< G > > PM = store::default_provided_t<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>>
requires ( vertex_list_graph<G> && (edge_list_graph<G> || out_edges_graph<G>) && std::output_iterator<std::remove_cvref_t<Target>, typename std::remove_cvref_t<Target>::value_type> && std::output_iterator<typename std::remove_cvref_t<Target>::value_type, vertex_of<G>> )
constexpr void graphle::alg::strongly_connected_components ( G &&  graph,
Target &&  target,
std::size_t  min_size = 0,
PV &&  stack_provider = store::get_default_storage_provider<store::storage_type::VECTOR, vertex_of<G>>(),
PVM &&  min_stack_provider = store::get_default_storage_provider<store::storage_type::VECTOR, vertex_of<G>>(),
PM &&  map_provider = store::get_default_storage_provider<store::storage_type::UNORDERED_MAP, vertex_of<G>, detail::tarjan_vertex_data<G>, vertex_hash_of<G>, vertex_compare_of<G>>() 
)
inlineconstexpr

Finds all strongly connected components (cycles) in the given directed graph using Tarjan's algorithm (Tarjan, R. (1972). Depth-First Search and Linear Graph Algorithms. SIAM Journal on Computing, 1(2), 146–160. doi:10.1137/0201010). This non-recursive version of the algorithm is based on the implementation by Thomas Ahle: https://stackoverflow.com/a/62006383

This overload outputs its data into the provided output iterator.

Parameters
graphA graphle::graph to find the strongly connected components of.
outputAn output iterator with a value type that is itself an output iterator, into which vertices can be pushed.
min_sizeStrongly connected components with a cycle length smaller than this value will be discarded. Typically, when e.g. searching for cyclic dependencies, you will want to discard all size-1 cycles, since these indicate vertices that do not have any dependencies at all.
stack_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use.
min_stack_providerAn optional storage-provider which can provide a vector-like type for the algorithm to use.
map_providerAn optional storage-provider which can provide a unordered-map-like type for the algorithm to use.
Graph Requirements:

Definition at line 84 of file strongly_connected_components.hpp.