title: Add node to network x only if a node with same attribute doesn`t exist
body: <p>I am very new to networkx and graphing in general and wanted your help.</p>
  
  <p>I am designing a graph where each node has a node_id (which is just the number of points i am iterating through to make my graph)  and five attributes.</p>
  
  <p>I.e.</p>
  
  <pre><code>G.add_node(node_id)
  G[id]['Coord1'] = 3
  G[id]['Coord2'] = 7
  G[id]['Coord3'] = None
  G[id]['Coord4'] = None
  G[id]['Coord5'] = None
  </code></pre>
  
  <p>So now i want to consider adding a new node, with some coordinates.</p>
  
  <p>Now before adding a new node to my graph i want to check that there isn't already a node which has an attribute (one of the coords) which is the same as the node i am intending to add.</p>
  
  <p>If there already exists a node which has a coord which is shared, then i will not add a new node but simply make some changes to the existing node.</p>
  
  <p>The only way i could think of doing this was to loop through all existing nodes in the graph and checking if one of the attributes is the same as the node i am contemplating adding. E.g.</p>
  
  <pre><code>find_node = [attrdict for n,attrdict in G.node.items() if attrdict['coord1'] == tempcoord ]    
  </code></pre>
  
  <p>Where tempcoord is the coordinate of interest on the node i am intending adding.</p>
  
  <p>This is clearly very inefficient to do this everytime i want to add node to have check all existing nodes, my question is: Is there a better way?</p>
  
  <p>I understand that networkx will not add a new node which has the same id, but that doesnt extend to nodes which share the same attribute correct?</p>
  
  <p>Alternatively, is it better to build the graph with all these "duplicate" nodes and then condense all nodes which have some shared attributes down into one node after i have added all nodes?</p>
  
  <p>Sorry for the somewhat convoluted explaination, i hope that it makes some sense.</p>