title: Adding nodes to a disconnected graph in order to fully connect the graph components, with inter-node distance constraints
body: <p>I have a graph where each node has a spatial position given by (x,y), and the edges between the nodes are only connected if the euclidean distance between each node is <em>sqrt(2)</em> or less. Here's my example:</p>
  <pre><code>import networkx
  
  G=nx.Graph()
  
  G.add_node(1,pos=(1,1))
  G.add_node(2,pos=(2,2))
  G.add_node(3,pos=(1,2))
  
  G.add_node(4,pos=(1,4))
  G.add_node(5,pos=(2,5))
  
  G.add_node(6,pos=(4,2))
  G.add_node(7,pos=(5,2))
  G.add_node(8,pos=(5,3))
  
  # Connect component one
  G.add_edge(1,2)
  G.add_edge(1,3)
  G.add_edge(2,3)
  
  # Connect component two
  G.add_edge(6,7)
  
  # Connect component three
  G.add_edge(6,8)
  G.add_edge(7,8)
  G.add_edge(4,5)
  
  pos=nx.get_node_attributes(G,'pos')
  
  nx.draw(G,pos)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Zkb4b.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zkb4b.png" alt="enter image description here" /></a></p>
  <p>My question is, how can I determine the optimal position and number of additional nodes such that the graph components are connected, whilst ensuring that any additional node is always within <em>sqrt(2)</em> of an existing node?</p>