-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add a few igraph algorithms to run via scripts/bench.py
#54
base: main
Are you sure you want to change the base?
Changes from all commits
973fb1c
ec81bd1
4bcc817
8e58900
76ab622
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
def overall_reciprocity(G): | ||
return G.reciprocity() | ||
|
||
|
||
def pagerank( | ||
G, | ||
alpha=0.85, | ||
personalization=None, | ||
max_iter=100, | ||
tol=1e-06, | ||
nstart=None, | ||
weight="weight", | ||
dangling=None, | ||
*, | ||
vertices=None, | ||
directed=True, | ||
arpack_options=None, | ||
implementation="prpack", | ||
): | ||
if personalization is not None: | ||
raise NotImplementedError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personalization is provided through the https://python.igraph.org/en/stable/api/igraph.GraphBase.html#personalized_pagerank |
||
if nstart is not None: | ||
raise NotImplementedError | ||
if dangling is not None: | ||
raise NotImplementedError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just confirming that the behaviour is the same as with |
||
rv = G.pagerank( | ||
vertices=vertices, | ||
directed=directed, | ||
damping=alpha, | ||
weights=weight, | ||
arpack_options=arpack_options, | ||
implementation=implementation, | ||
) | ||
return rv | ||
|
||
|
||
def transitivity(G): | ||
return G.transitivity_undirected() | ||
|
||
|
||
def average_clustering(G, nodes=None, weight=None, count_zeros=True): | ||
if nodes is not None: | ||
raise NotImplementedError | ||
# TODO: check results when `count_zeros=False` | ||
mode = "zero" if count_zeros else "nan" | ||
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is correct. |
||
return G.transitivity_avglocal_undirected(mode=mode, weights=weight) | ||
|
||
|
||
def clustering(G, nodes=None, weight=None): | ||
mode = "zero" # or "nan" | ||
return G.transitivity_local_undirected(vertices=nodes, mode=mode, weights=weight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
igraph.Graph.Adjacency
to convert from a SciPy sparse matrix.There is no direct support for reading MM files in igraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just what I was looking for, thanks!