Beispiel #1
0
 public AdjListGraph(int vertexCount)
 {
     this.vertexCount = vertexCount;
     Vertices         = new List <int>();
     Edges            = new LinkedListL[vertexCount];
     for (int i = 0; i < vertexCount; i++)
     {
         Vertices.Add(i);
         Edges[i] = new LinkedListL();
     }
 }
Beispiel #2
0
 public void displayGraph()
 {
     for (int k = 0; k < vertexCount; k++)
     {
         int         ii   = Vertices.IndexOf(k);
         LinkedListL node = Edges[ii];
         if (node.head != null)
         {
             Console.Write("nodes connected to " + ii + "->");
             node.display();
         }
     }
 }