title: Implementation of Adjacency list of a graph
body: <p>I am trying to implement the adjacency list for a non-weighted graph and a few questions/concerns.  i realize I need a linked list to store the edges and an array to store the vertices.Currently I have a (basic)Node class and a Graph class, which takes care of the addition of the edges to a particular vertex. This however does not explicitly define a linked list for the edges. I want to do a DFS and BFS and was wondering how should I go about it? Do I need to  changed the code that I already have to incorporate these methods or now. Help will be appreciated.</p>
  
  <pre><code> // Inside the graph class
  
    public boolean insertNode(NodeRecord n) {
      int j;
  
      if (isFull()) return false;
      for (j=0; j&lt;arraySize; j++)
          if (node[j]==null)
              break;
      node[j] = new Node(n);
      graphSize++;
      return true;
  }
  public boolean insertEdge(int nodeID, EdgeRecord e) {
      int j;
  
      for (j=0; j&lt;arraySize; j++)
          if (nodeID==((NodeRecord) node[j].item).getID())
              break;
      if (j&gt;=arraySize) return false;
      node[j].next = new Node(e, node[j].next);
              return true;
  }
  
   // inside the node class
  
      class Node&lt;E&gt; {
     E    item;
     Node&lt;E&gt; next;
  
  Node(E e) {
          item = e;
          next = null;
  }
  
  Node(E e, Node&lt;E&gt; newNext) {
          item = e;
          next = newNext;
  }
  
  Node(Node&lt;E&gt; n) {  // copy constructor
          item = n.item;
          next = n.next;
   }
  
   }
  
     public static void depthFirst(){
  
      for(int i=0;i&lt;mygraph.arraySize;i++){
          Node counter =mygraph.node[i];
          while(counter!=null){
           System.out.println(" " +counter.item);
           counter= counter.next;
         }
  
      }
  }
  </code></pre>