Graph.hh
Go to the documentation of this file.
T begin(T... args)
A directed edge represents a connection between two vertices. The connection is unidirectional,...
Definition: Edge.hh:268
A generic graph class. Both vertices and edges can store user information. A vertex could be created ...
Definition: Graph.hh:103
Vertex< V > & AddVertex(const std::string &_name, const V &_data, const VertexId &_id=kNullId)
Add a new vertex to the graph.
Definition: Graph.hh:137
bool RemoveVertex(Vertex< V > &_vertex)
Remove an existing vertex from the graph.
Definition: Graph.hh:545
size_t OutDegree(const Vertex< V > &_vertex) const
Get the number of edges incident from a vertex.
Definition: Graph.hh:416
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: Graph.hh:292
const EdgeType & EdgeFromVertices(const VertexId _sourceId, const VertexId _destId) const
Get a reference to an edge based on two vertices. A NullEdge object reference is returned if an edge ...
Definition: Graph.hh:640
const Vertex< V > & VertexFromId(const VertexId &_id) const
Get a reference to a vertex using its Id.
Definition: Graph.hh:610
size_t OutDegree(const VertexId &_vertex) const
Get the number of edges incident from a vertex.
Definition: Graph.hh:408
EdgeType & AddEdge(const VertexId_P &_vertices, const E &_data, const double _weight=1.0)
Add a new edge to the graph.
Definition: Graph.hh:211
const EdgeType & EdgeFromId(const EdgeId &_id) const
Get a reference to an edge using its Id.
Definition: Graph.hh:675
bool RemoveVertex(const VertexId &_vertex)
Remove an existing vertex from the graph.
Definition: Graph.hh:504
const VertexRef_M< V > Vertices(const std::string &_name) const
The collection of all vertices in the graph with name == _name.
Definition: Graph.hh:193
bool RemoveEdge(EdgeType &_edge)
Remove an existing edge from the graph. After the removal, it won't be possible to reach any of the v...
Definition: Graph.hh:601
size_t InDegree(const Vertex< V > &_vertex) const
Get the number of edges incident to a vertex.
Definition: Graph.hh:400
const EdgeRef_M< EdgeType > IncidentsFrom(const Vertex< V > &_vertex) const
Get the set of outgoing edges from a given vertex.
Definition: Graph.hh:451
const EdgeRef_M< EdgeType > IncidentsTo(const Vertex< V > &_vertex) const
Get the set of incoming edges to a given vertex.
Definition: Graph.hh:487
const EdgeRef_M< EdgeType > IncidentsFrom(const VertexId &_vertex) const
Get the set of outgoing edges from a given vertex.
Definition: Graph.hh:426
const EdgeRef_M< EdgeType > Edges() const
The collection of all edges in the graph.
Definition: Graph.hh:266
friend std::ostream & operator<<(std::ostream &_out, const Graph< VV, EE, EEdgeType > &_g)
Stream insertion operator. The output uses DOT graph description language.
const VertexRef_M< V > Vertices() const
The collection of all vertices in the graph.
Definition: Graph.hh:181
size_t RemoveVertices(const std::string &_name)
Remove all vertices with name == _name.
Definition: Graph.hh:553
bool Empty() const
Get whether the graph is empty.
Definition: Graph.hh:496
const EdgeRef_M< EdgeType > IncidentsTo(const VertexId &_vertex) const
Get the set of incoming edges to a given vertex.
Definition: Graph.hh:462
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: Graph.hh:351
bool RemoveEdge(const EdgeId &_edge)
Remove an existing edge from the graph. After the removal, it won't be possible to reach any of the v...
Definition: Graph.hh:572
Vertex< V > & VertexFromId(const VertexId &_id)
Get a mutable reference to a vertex using its Id.
Definition: Graph.hh:623
size_t InDegree(const VertexId &_vertex) const
Get the number of edges incident to a vertex.
Definition: Graph.hh:392
EdgeType & LinkEdge(const EdgeType &_edge)
Links an edge to the graph. This function verifies that the edge's two vertices exist in the graph,...
Definition: Graph.hh:235
Graph(const std::vector< Vertex< V >> &_vertices, const std::vector< EdgeInitializer< E >> &_edges)
Constructor.
Definition: Graph.hh:110
VertexRef_M< V > AdjacentsTo(const Vertex< V > &_vertex) const
Get all vertices that are directly connected with one edge to a given vertex. In other words,...
Definition: Graph.hh:384
VertexRef_M< V > AdjacentsFrom(const Vertex< V > &_vertex) const
Get all vertices that are directly connected with one edge from a given vertex. In other words,...
Definition: Graph.hh:331
An undirected edge represents a connection between two vertices. The connection is bidirectional,...
Definition: Edge.hh:205
A vertex of a graph. It stores user information, an optional name, and keeps an internal unique Id....
Definition: Vertex.hh:55
T emplace(T... args)
T end(T... args)
T endl(T... args)
T find(T... args)
T make_pair(T... args)
T move(T... args)
uint64_t VertexId
The unique Id of each vertex.
Definition: Vertex.hh:41
std::ostream & operator<<(std::ostream &_out, const Graph< VV, EE, DirectedEdge< EE >> &_g)
Partial template specification for directed edges.
Definition: Graph.hh:772
static const VertexId kNullId
Represents an invalid Id.
Definition: Vertex.hh:48
static const uint64_t MAX_UI64
64bit unsigned integer maximum value
Definition: Helpers.hh:339
Definition: Angle.hh:43
T cref(T... args)
Used in the Graph constructors for uniform initialization.
Definition: Edge.hh:45