~ubuntu-branches/ubuntu/utopic/python-networkx/utopic

« back to all changes in this revision

Viewing changes to networkx/algorithms/operators.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2011-03-19 12:19:16 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110319121916-xrhlpiwc9sa5e028
Tags: 1.4-1
* New upstream release; thanks to Yaroslav Halchenko for the report;
  Closes: #617677
* debian/rules
  - don't compress objects.inv; thanks to Michael Fladischer for the report;
    Closes: #608780
* debian/watch
  - updated to point to PyPi
* debian/control
  - bump python-sphinx versioned b-d-i to 1.0.1 minimum
  - added python-pygraphviz to b-d-i, needed for doc building
* debian/copyright
  - bump upstream and packaging copyright years
* debian/patches/{40_add_networkxcss, 50_boundary-test-fix.patch
                  60_remove_svn_refs.diff 70_set_matplotlib_ps_backend.patch}
  - removed since merged upstream
* debian/patches/{10_doc_relocation, 20_example_dirs_remove,
                  30_use_local_objects.inv}
  - refreshed/adapted to new upstream code

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
    return R
192
192
 
193
193
def difference(G,H,create_using=None):
194
 
    """Return a new graph that contains the edges that exist in G but not in H.  
 
194
    """Return a new graph that contains the edges that exist in G 
 
195
    but not in H.  
195
196
 
196
197
    The node sets of H and G must be the same.
197
198
 
229
230
    if set(G)!=set(H):
230
231
        raise nx.NetworkXError("Node sets of graphs not equal")        
231
232
    
232
 
    if G.number_of_edges()<=H.number_of_edges():
233
 
        if G.is_multigraph():
234
 
            edges=G.edges_iter(keys=True)
235
 
        else:
236
 
            edges=G.edges_iter()
237
 
        for e in edges:
238
 
            if not H.has_edge(*e):
239
 
                R.add_edge(*e)
 
233
    if G.is_multigraph():
 
234
        edges=G.edges_iter(keys=True)
240
235
    else:
241
 
        if H.is_multigraph():
242
 
            edges=H.edges_iter(keys=True)
243
 
        else:
244
 
            edges=H.edges_iter()
245
 
        for e in edges:
246
 
            if not G.has_edge(*e):
247
 
                R.add_edge(*e)
248
 
 
 
236
        edges=G.edges_iter()
 
237
    for e in edges:
 
238
        if not H.has_edge(*e):
 
239
            R.add_edge(*e)
249
240
    return R
250
241
 
251
242
def symmetric_difference(G,H,create_using=None ):