title: Hashmap representation of graph
body: <p>I have a text file with graph edges, for example</p>
  
  <p>1 2</p>
  
  <p>1 3</p>
  
  <p>2 5</p>
  
  <p>etc. ,
  and want to represent my graph in some way. I tried to use a hashmap, is it the best way to represent edges?
  And second question, how can I access first and second entries in my hashmap?
  My code here</p>
  
  <pre><code>    DataInputStream dStream = new DataInputStream(new FileInputStream("C:/Programming/Java/test.txt"));
      BufferedReader bReader = new BufferedReader(new InputStreamReader(dStream));
  
      HashMap&lt;Integer, Integer&gt; graphEdges = new HashMap&lt;Integer, Integer&gt;();
      String line;
      while( (line = bReader.readLine()) != null) {
          String[] firstSecond = line.split(" ");
          int firstDigit = Integer.parseInt(firstSecond[0]);
          int secondDigit = Integer.parseInt(firstSecond[1]);
  
          graphEdges.put(firstDigit, secondDigit);
      }
  
      System.out.println(graphEdges);
  
      bReader.close();
  }
  </code></pre>