DirectedGraph::outDegree

Function


int outDegree(const T& x);

Get the out degree of a specified vertex.

Parameters

x is label of specified vertex.

Return value

Return out degree of specified vertex.

Example

#include "HKUAL_graph.h"
#include <iostream>
using namespace std;
using namespace HKUAL;

int main(){
    DirectedGraph<string> g;
    g.addVertex("A");
    g.addVertex("B");
    g.addVertex("C");
    g.addEdge("A", "B");
    g.addEdge("A", "C");

    cout << g.outDegree("A") << endl;
    cout << g.outDegree("B") << endl;
    return 0;
}

Output

2
0

Time Complexity

, for is number of vertices.