the nodes and the edges of a graph collected one at a time, then frozen into a StaticGraph or an ArrayGraph
More...
#include <ADS/graph/GraphBuilder.h>
|
| using | Weight = W |
| | the type of the weights
|
| using | Edge = std::tuple< int , int , W > |
| | an edge \( ( u , v ) \) of weight \( w \)
|
|
| | GraphBuilder (int n=0, bool directed=true) |
| | the builder of the nodes \( 0 , \ldots , n - 1 \) and of no edge
|
| bool | directed (void) const |
| | whether the graph is oriented
|
| int | n (void) const |
| | the number of nodes
|
| int | m (void) const |
| | the number of edges, an unoriented one counted once
|
| const std::vector< Edge > & | edges (void) const |
| | the edges, in the order in which they were added
|
| void | reserve (std::size_t m) |
| | room for \( m \) edges, so that the next insertions do not move them
|
| int | addNode (void) |
| | a new node, the next name
|
| void | addEdge (int u, int v, const W &w=W()) |
| | the edge \( ( u , v ) \), or \( [ u , v ] \) if unoriented, of weight \( w \), after those already there, even if parallel to one of them
|
| StaticGraph< W > | toStaticGraph (void) const |
| | the graph in compressed rows, each row sorted by head
|
| ArrayGraph< W > | toArrayGraph (void) const |
| | the graph in compressed rows, each row in the order of insertion
|
template<class W = std::monostate>
class ADS::GraphBuilder< W >
the nodes and the edges of a graph collected one at a time, then frozen into a StaticGraph or an ArrayGraph
◆ Edge
template<class W = std::monostate>
an edge \( ( u , v ) \) of weight \( w \)
◆ Weight
template<class W = std::monostate>
◆ GraphBuilder()
template<class W = std::monostate>
the builder of the nodes \( 0 , \ldots , n - 1 \) and of no edge
- Precondition
- \( n \ge 0 \)
◆ addEdge()
template<class W = std::monostate>
the edge \( ( u , v ) \), or \( [ u , v ] \) if unoriented, of weight \( w \), after those already there, even if parallel to one of them
- Precondition
- \( u \) and \( v \) are two distinct nodes, fewer than \( 2^{31} - 1 \) edges
◆ addNode()
template<class W = std::monostate>
a new node, the next name
◆ directed()
template<class W = std::monostate>
whether the graph is oriented
◆ edges()
template<class W = std::monostate>
the edges, in the order in which they were added
◆ m()
template<class W = std::monostate>
the number of edges, an unoriented one counted once
◆ n()
template<class W = std::monostate>
◆ reserve()
template<class W = std::monostate>
room for \( m \) edges, so that the next insertions do not move them
◆ toArrayGraph()
template<class W = std::monostate>
the graph in compressed rows, each row in the order of insertion
In pseudocode:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{toArrayGraph}() \cr
2 & \quad \textbf{return}\ \mathrm{ArrayGraph}( n , E )\quad
\triangleright\ \text{one stable pass of counting sort by tail}
\end{array}}
\]
◆ toStaticGraph()
template<class W = std::monostate>
the graph in compressed rows, each row sorted by head
In pseudocode:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{toStaticGraph}() \cr
2 & \quad \textbf{return}\ \mathrm{StaticGraph}( n , E )\quad
\triangleright\ \text{two passes of counting sort, by head and by }
\text{tail}
\end{array}}
\]
The documentation for this class was generated from the following file: