I have a a vector<vector<string>> which holds the value if Nodes and edges.
i.e
1,2,1 // here 1 is starting node, 2 is ending node and 1 is weight
1,3,4
....
1 2
vector<vector<string>> inputdata;
total_node =4;
So far I created a 3 class, Node class, Edge Class and Graph class
class Node {
//This has node properties and Method to add adjacent node
//this has one property of type vector<edge> say edgeList
void addAdjacentNode(Node *orgNode, Node *endNode, int weight)
{
// create the edge and push_back this edge to edgeList
}
}
class Edge {
//this class has 3 prperties - orginatingNode, endingNode, cost
//method that assigns value to these properties
//Egde(Node *orgNode, Node *endNode, int cost)
{
orginatingNode = orgNode;
...
}
}
class Graph {
public:
void addNode(Node *node)
{
nodeList.push_back(node);
}
private:
vector<Node*> nodeList;
}
I am not sure, how should I make use of the class in the main program to create a graph .
How should I be calling my graph class to create a graph. Do I need to add any methods to any of my class to make it work.