Function
vector<Vertex <T> >getVertices();
Returns all vertices in the graph.
Parameters
None
Return value
Return the vector contain all vertices in the graph.
Example
#include "HKUAL_graph.h"
#include <iostream>
#include <vector>
using namespace std;
using namespace HKUAL;
int main(){
int n;
Graph<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
Time Complexity
, for is total number of vertices.
|