Function
Vertex<T> children(const T& x);
Get the children of a specified vertex x, which is all vertices that vertex x directed to.
Parameters
x is vertex specified.
Return value
Return a vector contain all parent vertices of x
Example
#include "HKUAL_graph.h"
#include <iostream>
#include <vector>
using namespace std;
using namespace HKUAL;
int main(){
Graph<string> g;
g.addVertex("A");
g.addVertex("B");
g.addVertex("C");
g.addEdge("A", "B");
g.addEdge("A", "C");
vector< Vertex<string> > v = g.neighbour("A");
for (int i = 0; i < v.size(); i++)
cout << v[i].label << endl;
return 0;
} |
Output
Time Complexity
, for is out degree of specified vertex and is total number of vertives
|