DirectedGraph::getVertices

Function


vector<Edge<T> >getVertices();

Returns all vertices in the directed graph.

Parameter

None

Return value

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");
	
    vector< Vertex<string> > v = g.getVertices();
    for (int i = 0; i < v.size(); i++)
        cout << v[i].label << endl;
    return 0;
}

Output

A
B
C
D

Time Complexity

, for is total number of vertices.

© The University of Hong Kong Algorithms Library - hkual@cs.hku.hk