#include<iostream>
using namespace std;
class Graph{
public:
void addVertex(int vertex);
void display();
TCSGraph(){
head = NULL;
}
~Graph(){}
private:
struct ListNode
{
string name;
struct ListNode *next;
};
ListNode *head;
};
void Graph::addVertex(int vertex){
ListNode *newNode;
ListNode *nodePtr;
string vName;
for(int i = 0; i < vertex ; i++ ){
cout << "what is the name of the vertex"<< endl;
cin >> vName;
newNode = new ListNode;
newNode->name = vName;
newNode->next = NULL;
if (!head)
head = newNode;
else{
nodePtr = head;
while(nodePtr->next)
nodePtr = nodePtr->next;
nodePtr->next = newNode;
}
}
}
void Graph::display(){
ListNode *nodePtr;
nodePtr = head;
while(nodePtr){
cout << nodePtr->name<< endl;
nodePtr = nodePtr->next;
}
}
void displayMenu(){
cout << endl << endl;
cout << " 1. Add a vertice" << endl;
cout << " 2. Displaying a graph by printing out the adjacency lists" << endl;
cout << " 0. Quit" << endl;
cout << endl;
cout << "Please enter your option: ";
}
int main(){
int choice;
int vertex;
bool done = false;
do{
displayMenu();
cin >> choice;
TCSGraph g;
if(choice==1){
cout << " how many vertex u wan to add" << endl;
cin >> vertex;
g.addVertex(vertex);
}
else if (choice==2){
g.display();
}
}while(!done);
return 0;
}

