Graph::Graph

Constructor


graph();

Constructs a graph.

Parameters

None

Return value

None

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");

    Graph<int> g2;
    g2.addVertex(1);
    g2.addVertex(2);
    g2.addVertex(3);
    g2.addEdge(1,2);
    g2.addEdge(1,3);

    return 0;
}

Output

None

Time Complexity

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