CGRA-ME
|
#include <GraphAlgorithms.h>
Classes | |
struct | TracebackResult |
Public Types | |
template<typename... Params> | |
using | VertexMap = std::decay_t< decltype(std::declval< MapGen >().template operator()<Params... >())> |
using | VertexList = std::vector< VertexID > |
using | VertexPath = VertexList |
template<typename... Params> | |
using | VertexSet = std::decay_t< decltype(std::declval< SetGen >().template operator()<Params... >())> |
using | PathList = std::vector< VertexPath > |
using | EdgeSet = std::set< std::pair< VertexID, VertexID > > |
Public Member Functions | |
GraphAlgorithms () | |
template<typename NewMapGen , typename NewSetGen > | |
GraphAlgorithms (int num_threads, NewMapGen &&vertex_map_gen, NewSetGen &&vertex_set_gen) | |
auto | withThreads (int num_threads) const |
template<typename NewMapGen > | |
auto | withMapGen (NewMapGen &&newVertexMapGen) const |
template<typename NewSetGen > | |
auto | withSetGen (NewSetGen &&newVertexSetGen) const |
template<typename... Params> | |
auto | makeVertexMap () const |
template<typename... Params> | |
auto | makeVertexSet () const |
Private Attributes | |
int | num_threads = 1 |
MapGen | vertex_map_gen = {} |
SetGen | vertex_set_gen = {} |
A generic graph algorithms library. Works with any object - the only required interface is a unary function called fanout
that takes a vertex id, and returns a range-like object (ie. has .begin() and .end()) of objects that can be converted to vertex ids.
First, a small example using a depth first visit:
struct Graph { std::vector<std::vector<int>> fanout_lists; const std::vector<int>& fanout(int ndesc) const { return fanout_lists.at(ndesc); } } g { {{1}, {2,0}, {3,0}, {1,0}} };
struct Visitor : DoNothingGraphVisitor<int> { void onExplore(int ndesc) { std::cout << ndesc << ' '; } } v;
GraphAlgorithms<int> g_algos;
// this should print: 1 2 3 0 g_algos.depthFirstVisit(g, 1, [](auto&&) { return false; }, v);
// (end example)
The GraphAlgorithms class itself store no information about any graphs or algorithms that are called. It only serves as a common configuration object for meta-parameters, such as the number of threads used, and what sort of map is used to store data indexed by vertices when running algorithms.
The default constructor is sufficient for most purposes. If configuration of the meta-parameters is desired, then other constructors can be used, or the builder-style member functions can be called.
Definition at line 72 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::EdgeSet = std::set<std::pair<VertexID, VertexID> > |
Definition at line 184 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::PathList = std::vector<VertexPath> |
Definition at line 183 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::VertexList = std::vector<VertexID> |
Definition at line 179 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::VertexMap = std::decay_t<decltype(std::declval<MapGen>().template operator()<Params...>())> |
Definition at line 178 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::VertexPath = VertexList |
Definition at line 180 of file GraphAlgorithms.h.
using GraphAlgorithms< VertexID, MapGen, SetGen >::VertexSet = std::decay_t<decltype(std::declval<SetGen>().template operator()<Params...>())> |
Definition at line 182 of file GraphAlgorithms.h.
|
inline |
Definition at line 102 of file GraphAlgorithms.h.
|
inline |
Definition at line 105 of file GraphAlgorithms.h.
|
inline |
Definition at line 168 of file GraphAlgorithms.h.
|
inline |
Definition at line 173 of file GraphAlgorithms.h.
|
inline |
A builder-style function for specifying the vertex map maker This function returns (by value) a GraphAlgorithms object that only differs in what object is used to make a vertex map.
Definition at line 137 of file GraphAlgorithms.h.
|
inline |
A builder-style function for specifying the vertex set maker This function returns (by value) a GraphAlgorithms object that only differs in what object is used to make a vertex set.
Definition at line 155 of file GraphAlgorithms.h.
|
inline |
A builder-style function for specifying the number of threads. This function returns (by value) a GraphAlgorithms object that only differs in the maximum number of threads.
Definition at line 120 of file GraphAlgorithms.h.
|
private |
Definition at line 82 of file GraphAlgorithms.h.
|
private |
The map generator object used. This object may be called in a concurrent manner, and therefore must be thread-safe. A nullary template operator()
must be supplied, which will be passed template parameters corresponding to the mapped type. See makeVertexMap
for exact details.
Definition at line 91 of file GraphAlgorithms.h.
|
private |
The set generator object used. This object may be called in a concurrent manner, and therefore must be thread-safe. A nullary template operator()
must be supplied, See makeVertexSet
for exact details.
Definition at line 99 of file GraphAlgorithms.h.