Commit 42e10c0c authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix get_hgap() for very small networks

parent c6c31faa
......@@ -217,8 +217,12 @@ def get_hgap(g):
g = GraphView(g, directed=False)
remove_parallel_edges(g)
T = hashimoto(g, compact=True, operator=True)
ew = scipy.sparse.linalg.eigs(T, k=1, which="LR", return_eigenvectors=False)
g.clear()
try:
ew = scipy.sparse.linalg.eigs(T, k=1, which="LR", return_eigenvectors=False)
except TypeError:
return numpy.nan
finally:
g.clear()
return float(ew.real[0])
@register("diameter", "(Pseudo-) diameter")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment