title: Create graph using adjacency list
body: <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  class TCSGraph{
      public:
          void addVertex(int vertex);
          void display();
          TCSGraph(){
  
              head = NULL;
          }
          ~TCSGraph();
  
      private:
          struct ListNode
          {
              string name;
              struct ListNode *next;
          };
  
          ListNode *head;
  }
  
  void TCSGraph::addVertex(int vertex){
      ListNode *newNode;
      ListNode *nodePtr;
      string vName;
  
      for(int i = 0; i &lt; vertex ; i++ ){
          cout &lt;&lt; "what is the name of the vertex"&lt;&lt; endl;
          cin &gt;&gt; vName;
          newNode = new ListNode;
          newNode-&gt;name = vName;
  
          if (!head)
          head = newNode;
          else
          nodePtr = head;
          while(nodePtr-&gt;next)
          nodePtr = nodePtr-&gt;next;
  
          nodePtr-&gt;next = newNode;
  
      }
  }
  
  void TCSGraph::display(){
      ListNode *nodePtr;
      nodePtr = head;
  
      while(nodePtr){
      cout &lt;&lt; nodePtr-&gt;name&lt;&lt; endl;
      nodePtr = nodePtr-&gt;next;
      }
  }
  
  int main(){
  int vertex;
  
  cout &lt;&lt; " how many vertex u wan to add" &lt;&lt; endl;
  cin &gt;&gt; vertex;
  
  TCSGraph g;
  g.addVertex(vertex);
  g.display();
  
  return 0;
  }
  </code></pre>