Function
int degree(const T& x);
Get the degree of a specified vertex.
x is label of specified vertex.
Return degree of specified vertex.
Example
#include "HKUAL_graph.h" #include <iostream> 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"); cout << g.degree("A") << endl; cout << g.degree("B") << endl; return 0; }
Output
Time Complexity
, for is number of vertices.