Change my input into an other format
<p>I kindly ask for your help because I am stuck. I have input in this format:</p>

<p>6 &lt;-- number of vertices</p>

<p>0 1 2 &lt;-- vertices directly linked to vertex 0 by an edge</p>

<p>1 0 3 4 </p>

<p>I need this in my program to be like this:</p>

<pre><code>int[][] edges = {
   {0,1}, {0,2}, 
   {1,2}, {1,3}, 
   {2,5},
   {3,2}, {3,4},
   {5,4}
};
</code></pre>

<p>I got stuck, and think I might have to work with a list? This is what I had so far:</p>

<pre><code>public class Part1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt(); // number of vertices
        String[] input = new String[k];
        int[][] edges;
        String[] tokens = new String[k];
        int[] vertices = new int[k];
        int[] integers = new int[k];
        int p = 0;

        for (int i = 0; i &lt; k; i++) {
            vertices[i] = i;
            input[i] = scanner.nextLine();
            tokens = input[i].split("[\\s+]");
            integers[i] = Integer.parseInt(tokens[i].trim());
            for (int j = 0; j &lt; integers.length - 1; j++) {
                edges[p][i] = integers[0];
                edges[p][2] = integers[j];
                p++;

            }
        }
    }
}
</code></pre>

<p>I hope someone can help me. </p>
