title: Efficient way to find nearest node in euclidean distance with networkx
body: <p>I am trying to implement Rapidly-Exploring Random Tree (RRT) using networkx library in Python. </p>
  
  <p>In my code, each node is defined as <code>G.add_node(node_idx, pos = (x,y))</code>. The 'pos' attribute contains the position information of each node. One of the critical steps in RRT algorithm is to first randomly sample a point within the configuration space, then select a node with the shortest Euclidean distance as a parent node and create a child node with some step size. (assuming no obstacle is in the way)</p>
  
  <p>A naive approach is to loop through all the nodes with respect to the sample point and calculate all the Euclidean distances, then return a node with the smallest distance. Are there any other better ways to achieve this? Or any built-in libraries that can do it for me? </p>