title: How to create a networkx Graph using 2D np array as input
body: <p>My algorithm outputs the set of vertices describing objects in 3D space (x, y, z). In this case, there are two objects:</p>
  
  <pre><code>verts = 
  [[0.1 1.  1. ]  [1.  1.  0.1]  [1.  0.1 1. ]  [1.  1.  1.9]  [1.  1.9 1. ]
   [1.9 1.  1. ]  [7.1 8.  8. ]  [8.  8.  7.1]  [8.  7.1 8. ]  [8.  8.  8.9]
   [8.  8.9 8. ]  [8.9 8.  8. ]]
  </code></pre>
  
  <p>There are two tetrahedrons, one confined between centered on (1, 1, 1), the other on (8, 8, 8). My goal is to use breadth-first search to identify that the objects are separate, and then classify each. I have not been able to get the data in the correct form for my algorithm.</p>
  
  <p>Instead, I intend to use the networkx module, specifically using the <a href="https://networkx.github.io/documentation/stable/reference/classes/graph.html" rel="nofollow noreferrer">Graph</a> class, which takes ndarrays as input. I have tried:</p>
  
  <pre><code>import networkx as nx
  import numpy as np
  
  graph = Graph(verts)
  for idx, graph in enumerate(nx.connected_components(graph)):
      print("Graph ",idx, " in ", graph,'\n\n',file=open("output.txt","a"))     
  </code></pre>
  
  <p>However, I cannot create graph. Instead, I get the error:</p>
  
  <pre><code>"Input is not a correct numpy matrix or array.")
  networkx.exception.NetworkXError: Input is not a correct numpy matrix or array.
  </code></pre>
  
  <p>This confuses me because type of verts = numpy.ndarray.     </p>
  
  <p>I am open to either using networkx for this task, or developing some other strategy. Additionally, please let me know if there are any edits that might make this post more clear. </p>
  
  <p><img src="https://i.imgur.com/h7NXsCD.png" alt="Tetrahedrons"></p>
  
  <p>Edit: One thing that may help is another output, faces. These 'define triangular faces via referencing vertex indices from verts.' I believe these can be used to 'connect' or draw lines from vertex to vertex, eventually to create a dictionary.</p>
  
  <pre><code>faces = 
  [[ 2  1  0]  [ 0  3  2]  [ 1  4  0]  [ 0  4  3]  [ 5  1  2]  [ 3  5  2]
   [ 5  4  1]  [ 4  5  3]  [ 8  7  6]  [ 6  9  8]  [ 7 10  6]  [ 6 10  9]
   [11  7  8]  [ 9 11  8]  [11 10  7]  [10 11  9]]
  
  </code></pre>
  
  <p>A method has been proposed, and it works for this set of data. However, it does not work for all. This edit uploads a new set of data.</p>
  
  <pre><code>verts = 
  [[0.1 1.  1. ]  [1.  1.  0.1]  [1.  0.1 1. ]  [1.  1.  1.9]  [1.  1.9 1. ]  [1.9 1.  1. ]
   [3.1 1.  4. ]  [4.  1.  3.1]  [4.  0.1 4. ]  [4.  1.  4.9]  [4.  1.9 4. ]  [5.  1.  3.1]
   [5.  0.1 4. ]  [5.  1.  4.9]  [5.  1.9 4. ]  [5.9 1.  4. ]  [7.1 8.  8. ]
   [8.  8.  7.1]  [8.  7.1 8. ]  [8.  8.  8.9]  [8.  8.9 8. ]  [9.  8.  7.1]
   [9.  7.1 8. ]  [9.  8.  8.9]  [9.  8.9 8. ]  [9.9 8.  8. ]]
  </code></pre>
  
  <p>And it looks like this. 
  <img src="https://i.imgur.com/DWHwIqH.png" alt="tetra_3"></p>