Skip to content

Commit

Permalink
Revised code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemal Maulana committed Apr 28, 2014
1 parent 0b19c53 commit 31868a4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions networkx/classes/function.py
Expand Up @@ -439,11 +439,14 @@ def non_edges(graph):
non_edges : iterator
Iterator of edges that are not in the graph.
"""
S = set()
for u in graph.nodes_iter():
for v in non_neighbors(graph, u):
if (u, v) not in S:
S.add((u, v))
if not graph.is_directed():
S.add((v, u))
if graph.is_directed():
for u in graph.nodes_iter():
for v in non_neighbors(graph, u):
yield (u, v)
else:
S = set()
for u in graph.nodes_iter():
for v in non_neighbors(graph, u):
if (u, v) not in S:
yield (u, v)
S.add((v, u))

0 comments on commit 31868a4

Please sign in to comment.