gz/math/graph/GraphAlgorithms.hh
Go to the documentation of this file.
A generic graph class. Both vertices and edges can store user information. A vertex could be created ...
Definition: gz/math/graph/Graph.hh:110
Vertex< V > & AddVertex(const std::string &_name, const V &_data, const VertexId &_id=kNullId)
Add a new vertex to the graph.
Definition: gz/math/graph/Graph.hh:144
VertexRef_M< V > AdjacentsFrom(const VertexId &_vertex) const
Get all vertices that are directly connected with one edge from a given vertex. In other words,...
Definition: gz/math/graph/Graph.hh:296
const Vertex< V > & VertexFromId(const VertexId &_id) const
Get a reference to a vertex using its Id.
Definition: gz/math/graph/Graph.hh:605
EdgeType & AddEdge(const VertexId_P &_vertices, const E &_data, const double _weight=1.0)
Add a new edge to the graph.
Definition: gz/math/graph/Graph.hh:215
const EdgeRef_M< EdgeType > IncidentsFrom(const VertexId &_vertex) const
Get the set of outgoing edges from a given vertex.
Definition: gz/math/graph/Graph.hh:430
const EdgeRef_M< EdgeType > Edges() const
The collection of all edges in the graph.
Definition: gz/math/graph/Graph.hh:270
const VertexRef_M< V > Vertices() const
The collection of all vertices in the graph.
Definition: gz/math/graph/Graph.hh:185
VertexRef_M< V > AdjacentsTo(const VertexId &_vertex) const
Get all vertices that are directly connected with one edge to a given vertex. In other words,...
Definition: gz/math/graph/Graph.hh:355
T count(T... args)
T empty(T... args)
T end(T... args)
T endl(T... args)
T find(T... args)
T front(T... args)
T insert(T... args)
T make_pair(T... args)
std::pair< std::vector< VertexId >, bool > Ancestors(const Graph< V, E, EdgeType > &_graph, const VertexId &_vertex)
Walk parent edges from _vertex up to a root and return the chain of ancestors in walk order (immediat...
Definition: gz/math/graph/GraphAlgorithms.hh:360
uint64_t VertexId
The unique Id of each vertex.
Definition: gz/math/graph/Vertex.hh:41
Graph< V, E, EdgeType > Subgraph(const Graph< V, E, EdgeType > &_graph, const VertexId &_root)
Extract the subgraph induced by _root and all descendants reachable from it. Vertices and edges are c...
Definition: gz/math/graph/GraphAlgorithms.hh:480
static const VertexId kNullId
Represents an invalid Id.
Definition: gz/math/graph/Vertex.hh:48
std::vector< VertexId > DepthFirstSort(const Graph< V, E, EdgeType > &_graph, const VertexId &_from)
Depth first sort (DFS). Starting from the vertex == _from, it visits the graph as far as possible alo...
Definition: gz/math/graph/GraphAlgorithms.hh:91
std::map< VertexId, CostInfo > Dijkstra(const Graph< V, E, EdgeType > &_graph, const VertexId &_from, const VertexId &_to=kNullId)
Dijkstra algorithm. Find the shortest path between the vertices in a graph. If only a graph and a sou...
Definition: gz/math/graph/GraphAlgorithms.hh:187
std::unordered_set< VertexId > DescendantsSet(const Graph< V, E, EdgeType > &_graph, const VertexId &_vertex)
Set of all descendants of _vertex (including _vertex itself). Equivalent to BreadthFirstSort + insert...
Definition: gz/math/graph/GraphAlgorithms.hh:515
VertexId LowestCommonAncestor(const Graph< V, E, EdgeType > &_graph, const VertexId &_a, const VertexId &_b)
Lowest common ancestor of two vertices in a directed forest. Walks _a up to root collecting ancestors...
Definition: gz/math/graph/GraphAlgorithms.hh:439
std::pair< double, VertexId > CostInfo
Used in Dijkstra. For a given source vertex, this pair represents the cost (first element) to reach a...
Definition: gz/math/graph/GraphAlgorithms.hh:43
bool IsAncestor(const Graph< V, E, EdgeType > &_graph, const VertexId &_ancestor, const VertexId &_descendant)
Test whether _ancestor lies on the parent chain above _descendant. O(depth) – walks _descendant up vi...
Definition: gz/math/graph/GraphAlgorithms.hh:393
std::vector< UndirectedGraph< V, E > > ConnectedComponents(const UndirectedGraph< V, E > &_graph)
Calculate the connected components of an undirected graph. A connected component of an undirected gra...
Definition: gz/math/graph/GraphAlgorithms.hh:271
std::vector< VertexId > BreadthFirstSort(const Graph< V, E, EdgeType > &_graph, const VertexId &_from)
Breadth first sort (BFS). Starting from the vertex == _from, it traverses the graph exploring the nei...
Definition: gz/math/graph/GraphAlgorithms.hh:53
UndirectedGraph< V, E > ToUndirectedGraph(const DirectedGraph< V, E > &_graph)
Copy a DirectedGraph to an UndirectedGraph with the same vertices and edges.
Definition: gz/math/graph/GraphAlgorithms.hh:316
static const double MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: gz/math/Helpers.hh:257
Definition: gz/math/AdditivelySeparableScalarField3.hh:28
T pop(T... args)
T push_back(T... args)
T push(T... args)
T top(T... args)