Function
vector<Edge<T> >getEdges();
Returns all edges in the directed graph.
None
Return the vector contain all edges in the graph.
Example
#include "HKUAL_graph.h" #include <iostream> #include <vector> using namespace std; using namespace HKUAL; int main(){ int n; DirectedGraph<string> g; g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addEdge("A","B"); g.addEdge("A","C"); g.addEdge("B","C"); g.addEdge("C","D"); g.addEdge("A","D"); vector<DirectedEdge<string> > v = g.getEdges(); for (int i = 0; i < v.size(); i++) cout << v[i].X << ' ' << v[i].Y << endl; return 0; }
Output
A B A C B C C D A D
Time Complexity
, for is total number of vertices.