title: Computing the Difference between two graphs 'edge wise' in networkx
body: <p>I would like to compare two graphs using networkx library. 
  I want to try on hardcoded example containing 3 nodes. One of the graphs is referenced so I want to check if in the second one the edges are in the same place. I was thinking about simple algorithm which will subtract reference graph from a given one and if the result is not an empty graph then it returns false.</p>
  
  <p>My code is as follows but it is not working:</p>
  
  <pre><code>import networkx as nx
  import matplotlib.pyplot as plt
  
  
  S=nx.DiGraph()#S-sample graph
  
  S.add_nodes_from([0,1,2])
  S.add_edge(0,2)
  S.add_edge(1,2)
  
  nx.draw(S)
  #plt.savefig("S.png")
  #plt.show()
  
  R=nx.DiGraph()#R-reference graph
  
  R.add_nodes_from([0,1,2])
  R.add_edge(1,2)
  
  nx.draw(R)
  #plt.savefig("R.png")
  #plt.show()
  
  def difference(S, R):
    DIF=nx.create_empty_copy(R)
    DIF.name="Difference of (%s and %s)"%(S.name, R.name)
    if set(S)!=set(R):
      raise nx.NetworkXError("Node sets of graphs is not equal")
  
   # if S.is_multipgraph():
   #   edges=S.edges_iter(keys=True)
   # else:
    edges=S.edges_iter()
    for e in edges:
      if not R.has_edge(*e):
        DIF.add_edge(*e)
    return DIF
  
  D=difference(S, R)
  plt.show(D)
  </code></pre>