public void printGraph(GraphAdjList <T> graph)
 {
     for (int v = 0; v < graph.nodes.Length; v++)
     {
         Console.WriteLine("Adjacency list of vertex " + graph.nodes[v].Data);
         Console.WriteLine("head");
         for (int i = 0; i < graph.nodes[v].AdjListArray.Count; i++)
         {
             Console.Write(" -> " + graph.nodes[v].AdjListArray[i]);
         }
         Console.WriteLine("\n");
     }
 }
        public static void Test()
        {
            // create the graph given in above figure
            int V = 5;
            GraphAdjList <int> graph = new GraphAdjList <int>(V);

            graph.addEdge(graph, 0, 1);
            graph.addEdge(graph, 0, 4);
            graph.addEdge(graph, 1, 2);
            graph.addEdge(graph, 1, 3);
            graph.addEdge(graph, 1, 4);
            graph.addEdge(graph, 2, 3);
            graph.addEdge(graph, 3, 4);

            // print the adjacency list representation of
            // the above graph
            graph.printGraph(graph);
        }
 public void addEdge(GraphAdjList <T> graph, int src, int dest)
 {
     nodes[src].AdjListArray.Add(dest);
     // Since graph is undirected, add an edge from dest to src also
     nodes[dest].AdjListArray.Add(src);
 }