#include "BaseGraph/directed_graph.hpp"
Directed graph (unlabeled)
DirectedGraph class is a special case of LabeledDirectedGraph that has no edge labels. They share most of their methods.
Usage
To create a DirectedGraph of 5 vertices, use
BaseGraph::DirectedGraph graph(5);
The vertices of this graph are labeled 0, 1, 2, 3, 4. To add an edge, we use
the method addEdge
graph.addEdge(0, 1);
graph.addEdge(3, 2);
If we try to make an operation on a vertex outside the graph range, an
std::out_of_range exception is thrown
// graph.addEdge(1, 5); throws std::out_of_range
Here is a small example that computes the out degree of a vertex
1#include "BaseGraph/directed_graph.hpp"
2
3#include <iostream>
4
5int main() {
6 BaseGraph::DirectedGraph graph(5);
7 graph.addEdge(0, 1);
8 graph.addEdge(0, 3);
9 graph.addEdge(1, 0);
10
11 std::cout << graph << std::endl;
12 std::cout << "The out degree of vertex 0 is " << graph.getOutDegree(0)
13 << std::endl;
14 return 0;
15}
Detailed documentation
-
using BaseGraph::DirectedGraph = LabeledDirectedGraph<NoLabel>
Unlabeled directed graph.