title: How to create edges in a network conditionally (using python Networkx package) based on other edges between nodes?
body: <p>I have a dataset that shows parent-child relationship but no child-child relationship for siblings. I'm building a network using python's Networkx package (python version 3.6). I would like to add edges between siblings (if children share parents, they are siblings). How can I do this?</p>
  
  <p>I've found some questions about conditional edge creation but in these questions the condition does not depend on other node properties (for example, existing edges to certain nodes):</p>
  
  <p><a href="https://stackoverflow.com/questions/18261587/python-networkx-remove-nodes-and-edges-with-some-condition">python networkx remove nodes and edges with some condition</a></p>
  
  <p>But I'm not sure how to formulate the condition in my case, to achieve what I want.</p>
  
  <pre><code>import networkx as nx
  
  dat = {'child':[1,1,4,4,5,5,8,8], 'parent':[2,3,2,3,6,7,6,7]} 
  
  # Create DataFrame 
  data = pd.DataFrame(dat) 
  
  # Create graph with known connections
  G = nx.Graph()
  
  def create_edges(row):
      return G.add_edge(row['child'],row['parent'])
  
  data.apply(create_edges, axis=1)
  </code></pre>
  
  <p>I would like to create edge between nodes 1 and 4, and nodes 5 and 8 (because they share parents and are clearly siblings) but not between 1 and 5, or 4 and 8. </p>