Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non edges enumeration #1124

Merged
merged 3 commits into from Apr 29, 2014
Merged

Conversation

kmkurn
Copy link

@kmkurn kmkurn commented Apr 28, 2014

Here is the implementation of non-existent edges enumeration as discussed in #1117. With this, one can perform link prediction algorithm to a graph by something like:

import networkx as nx

def linkpred(graph):
    for (u, v) in nx.non_edges(graph):
        p = nx.common_neighbors(graph, u, v)
        yield (u, v, p)

Please let me know what you think.

# All possible edges exist
graph = nx.complete_graph(5)
nedges = list(nx.non_edges(graph))
assert len(nedges) == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assert_equal and friends.

@ysitu
Copy link
Contributor

ysitu commented Apr 29, 2014

Save for the comments above this otherwise looks good to me.

@chebee7i
Copy link
Member

We can merge this once those changes are done.

chebee7i added a commit to chebee7i/networkx that referenced this pull request Apr 29, 2014
@chebee7i chebee7i merged commit 31868a4 into networkx:master Apr 29, 2014
@kmkurn kmkurn deleted the non-edges-enumeration branch April 30, 2014 05:44
@hagberg hagberg added this to the networkx-1.9 milestone May 13, 2014
@ysitu ysitu added the 1.9 label May 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants