title: Converting a pandas dataframe to a networkx graph
body: <p>I have a dataframe like the following:</p>
  
  <pre><code>    X  Y
  0   1  1
  1   1  2
  2   2  1
  3   2  3
  4   3  3
  </code></pre>
  
  <p>I want to create an undirected graph in networkx where each row of the dataframe corresponds to a node in the graph (the name of each node should be the index value of the dataframe), and an edge is drawn between nodes if the two nodes share either the same X or Y values. How can this be done?</p>