summaryrefslogtreecommitdiff
path: root/networkx/classes/function.py
diff options
context:
space:
mode:
authorKemal Maulana <kemskems12@gmail.com>2014-04-28 17:15:49 +0900
committerKemal Maulana <kemskems12@gmail.com>2014-04-28 17:15:49 +0900
commit31868a4fc81f3decf46dfaecc514b81ee517fbf6 (patch)
tree998067f35e07e6757d9ef783eb87aaade611a1bb /networkx/classes/function.py
parent0b19c537ca74cef26b02359cb406726cbae05eab (diff)
downloadnetworkx-31868a4fc81f3decf46dfaecc514b81ee517fbf6.tar.gz
Revised code
Diffstat (limited to 'networkx/classes/function.py')
-rw-r--r--networkx/classes/function.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/networkx/classes/function.py b/networkx/classes/function.py
index f08fec1e..9f035b98 100644
--- a/networkx/classes/function.py
+++ b/networkx/classes/function.py
@@ -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))