title: How do I convert a matrix into an unweighted graph or tree?
body: <p>I have a matrix called array[][] with equal width and height dimensions. The data it contains looks like this</p>
  
  <pre><code>        #1    #2     #3       #4     #5    #6        #7   #8
      #1   0    100    -1       10     -1    -1        -1   100
      #2  100     0    -1       -1     10    10        -1    -1
      #3  -1     -1     0     1000    100    -1      1000    -1 
      #4  50     -1   720       -1    -1     -1       -1     -1  
      #5  -1     10   100       -1      0    -1       100    -1
      #6  -1     10    -1       -1     -1     0        50  2000
      #7  -1     -1  1000       -1    100    10         0    -1
      #8  100    -1    -1       -1     -1  1000        -1     0
  </code></pre>
  
  <p>A -1 means that there is no path from #x to #y, positive numbers mean there is. I'm trying to convert this to a graph or tree to make it easier to implement a minimum hop algorithm. Is there a simple way to convert it?</p>