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; } }
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); } }
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; }
public SLList () { Head = null; }
public SLNode(int val) { Value = val; Next = null; }