Note that there are some explanatory texts on larger screens.

plurals
  1. POjava moving in a two dimensional matrix
    primarykey
    data
    text
    <p>I have a two dimensional array int matrix[numNodes][numArcs]. This is an Incidence matrix. </p> <p>Now, if we wish to add an arc, we have to check those nodes exist and the arc does not exist. This part works well. The following thing i need to do, is find an empty column to add the arc. So the matrix is full of zeros at the beginning . So its simple, you search each column until you find a column full of zeros. Sounds simple but its now working. This part of the code is the following:</p> <pre><code> outerloop: for (int i = 0; i &lt; numArcs; i++){ for (int j = 0; j &lt; numNodes; j++){ if (matriz[j][i] != 0) break; //It finds a number != 0 so it should move to the next column //If it gets here, the whole column was full of zeros column = i; key = true; break outerloop; } } </code></pre> <p>I use the key to know i found the column, because if i dont its because the matrix is full and i need to duplicate it. Thats another issue non-related to this problem. </p> <p>Now, i tried to figure out the problem and i notice the following: its only checking these positions: </p> <pre><code>01 02 03 03 </code></pre> <p>As you can see, its just checking the first position of each column and not going all the way down how it should. To me it makes no sense. NumNode is 10 in my example, so it should go all the way down. </p> <p>Edit: My exact example the matrix is like this:</p> <pre><code> -1 -1 -1 0 0 0 .... 0 1 0 0 0 ... 0 0 1 0 0 ..... </code></pre> <p>So when it reaches the fourth column, it reads that zero and return thats the empty column. It does the same for the next n arcs I added. the following arcs i add don't touch the first row any more. thanks for the help</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload