Graph::radius

Function


int radius();

Get the radius of the graph.

Parameter

None

Return value

Return radius of the graph.

Example

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

int main(){
    Graph<string> g;
    g.addVertex("A");
    g.addVertex("B");
    g.addVertex("C");
    g.addVertex("D");
    g.addEdge("A","B");
    g.addEdge("A","C");
    g.addEdge("B","D");
    
cout << g.radius() << endl;
    return 0;
}

Output

2

Time Complexity

, for is number of edges and is total number of vertives

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