title: How to follow edges in a graph represented by a Map in Java 7?
body: <pre><code>Collection&lt;String&gt; sources = new ArrayList&lt;String&gt;();
          sources.add("a");
          sources.add("c");
          sources.add("x");
          sources.add("a1");
          sources.add("y");
  
          Collection&lt;String&gt; targets = new ArrayList&lt;String&gt;();
          targets.add("b");
  
          Collection&lt;String&gt; overAllFieldMaps = new ArrayList&lt;String&gt;();
          overAllFieldMaps.add("a&gt;b");
          overAllFieldMaps.add("c&gt;a");
          overAllFieldMaps.add("x&gt;c");
          overAllFieldMaps.add("a1&gt;x");
          overAllFieldMaps.add("y&gt;c");
  
          Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
          for (String aFieldMap : overAllFieldMaps) {
              String[] splittedField = aFieldMap.split("\\&gt;");
              String sourceName = splittedField[0];
              String targetName = splittedField[1];
              map.put(sourceName, targetName);
          }
  
  
  
  Expected Result:
  
  
  a -&gt; b
  
  c -&gt; a -&gt; b
  
  x -&gt; c -&gt; a -&gt; b
  
  a1 -&gt; x -&gt; c -&gt; a -&gt; b
  
  y -&gt; c -&gt; a -&gt; b
  </code></pre>
  
  <p>I am trying to achieve the recursion of path among the data available in map. Can anyone help on this? </p>
  
  <p>In simple ,what i am trying to achieve is Connect by Prior / Common Table Expression equivalent in Java. </p>