title: printing graph vertex and edge source/target - JGraphT
body: <p>I'm creating a graph of flights where the user 
  I want to be able to print my graph out like:</p>
  
  <pre><code>Edinburgh &lt;-&gt; Heathrow
  Heathrow &lt;-&gt; Amsterdam
  etc....
  </code></pre>
  
  <p>I have an idea to do this by getting the edge source and the edge target, the edge being the "&lt;->" , the source being for example "Edinburgh" and the target being "Heathrow".</p>
  
  <p>I've tried looping through the String array and printing, such as graph.getEdge(sourceVertext, targetVertex), but I can't seem to get it working.</p>
  
  <p>I'll only use a couple of examples in the code.</p>
  
  <p>Note: If I try printing the array after setting edge weights, I get an illegal argument exception. If anyone could please explain why this is happening that would also be great :) thanks.</p>
  
  <pre><code>public static void main(String[] args) {
  
      SimpleDirectedWeightedGraph&lt;String, DefaultWeightedEdge&gt; airport = new SimpleDirectedWeightedGraph&lt;String, DefaultWeightedEdge&gt;(
              DefaultWeightedEdge.class);
  
      String[] array = { "Edinburgh", "Heathrow", "Amsterdam" };
  
      System.out.println(" ");
      System.out.println("The following destinations are used: " + "\n");
  
      for (String s : array) {
          System.out.println(s); // prints the array elements
      }
  
      System.out.print("");
  
      for (String s : array) {
          System.out.print(airport.getEdgeSource(s) + airport.getEdgeTarget(s));
          // OR....
          // System.out.print(airport.getEdge(sourceVertex, targetVertex));
      }
  
      DefaultWeightedEdge EH1 = airport.addEdge("Edinburgh", "Heathrow");
      DefaultWeightedEdge HE1 = airport.addEdge("Heathrow", "Edinburgh");
      airport.setEdgeWeight(EH1, 110);
      airport.setEdgeWeight(HE1, 110);
  
      DefaultWeightedEdge HA2 = airport.addEdge("Heathrow", "Amsterdam");
      DefaultWeightedEdge AH2 = airport.addEdge("Amsterdam", "Heathrow");
      airport.setEdgeWeight(HA2, 100);
      airport.setEdgeWeight(AH2, 100);
  
      System.out.println("");
  }
  </code></pre>