title: What am I missing in my Warshall algorithm?
body: <p>I am trying to implement Warshall's algorithm to find the transitive closure of an adjacency matrix. This is what I have for the function:</p>
  
  <pre><code>public static int[][] warshall(int A[][]){
      int R[][] = A;
      for (int k = 1; k &lt; n; k++) {
          for (int i = 1; i &lt; n; i++) {
              for (int j = 1; j &lt; n; j++) {
                  if ((R[i][j] == 1) || ((R[i][k] == 1) &amp;&amp; (R[k][j] == 1))) {
                      A[i][j] = 1;
                  }
              }
          }
          R = A.clone();
      }
      return A;
  }
  </code></pre>
  
  <p>I'm using the following adjacency matrix to test:</p>
  
  <pre><code>0100
  0001
  0000
  1010
  </code></pre>
  
  <p>Which should result in :</p>
  
  <pre><code>1111
  1111
  0000
  1111
  </code></pre>
  
  <p>I'm not getting anywhere close to this. Can anyone readily see what I am missing?</p>
  
  <p>Thanks for any tips or suggestions.</p>