Java code for creating paths
<p>Trying to code this in java. Please suggest any algorithm that would work for this scenario.
 The input is:</p>

<pre><code>Col A   Col B
A       B
A       C
B       D
C       A
C       B
C       E
D       A
D       B
E       A
</code></pre>

<p>I am trying to make combinations such as Output:</p>

<pre><code>A   B   D   A       
A   C   A           
A   C   B   D   A   
A   C   E   A       
B   D   B           
C   A   B   D   A   C
C   A   C           
C   B   D   A   C   
C   E   A   C

|
|
|
</code></pre>

<p>and so on. 
The output should have the starting point and ending point as the same. </p>

<p>Another way of looking at it is, you are starting from a node A and you have to get back to node A, so your path would be from A to B then B to D(because from B you can only go to one node i.e. D), then D to A. So, col A and Col B gives you the possible paths, for example from A you can only go to B and C, and not D and E. I hope this helps.
Also, is there any way to restrict the no. of nodes for a solution ?</p>

<p>Please suggest some ideas.</p>
