Пример #1
0
 public Graph (int[] vertexValues)
 {
     Adjs = new SLNode[vertexValues.Length];
     for (int i=0; i<vertexValues.Length; i++)
     {
         SLNode vert = new SLNode(vertexValues[i]);
         Adjs[i] = vert;
     }
 }
Пример #2
0
 private void myAddEdge(SLNode from, int toVal)
 {
     if (from.Next == null) 
     {
         SLNode newNode = new SLNode(toVal);
         from.Next = newNode;
         return;
     }
     else
     {
         myAddEdge(from.Next, toVal);
     }
 }
Пример #3
0
 public void ReverseLinkedList()
 {
     if (Head == null) 
         return;
     SLNode curr = Head;
     if (curr.Next == null)
         return;
     SLNode next = curr.Next;
     SLNode prev = null;
     while (curr.Next != null)
     {
         curr.Next = prev;
         prev = curr;
         next = curr.Next;
     }
     curr.Next = prev;
     Head = curr;
 }
Пример #4
0
 public SLList () 
 {
     Head = null;
 }
Пример #5
0
 public SLNode(int val) 
 {
     Value = val;
     Next = null;
 }