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

Improve analyses of very large graphs

parent 327c7bfe
......@@ -200,7 +200,17 @@ def get_tgap(g):
if 2 >= g.num_vertices() - 1:
return numpy.nan
T = transition(g, operator=True)
ew = scipy.sparse.linalg.eigs(T, k=2, which="LR", return_eigenvectors=False)
k = numpy.array(g.degree_property_map("out").fa, dtype="float")
k /= numpy.linalg.norm(k)
def matvec(x):
return T.matvec(x) - numpy.dot(k, x) * k
Tp = scipy.sparse.linalg.LinearOperator(T.shape, matvec=matvec)
try:
ew = scipy.sparse.linalg.eigs(Tp, k=1, which="LR",
return_eigenvectors=False,
tol=1e-6)
except scipy.sparse.linalg.eigen.arpack.ArpackNoConvergence:
return numpy.nan
return float(min(ew.real))
@register("mixing_time", "Random walk mixing time", "log")
......@@ -215,17 +225,20 @@ def get_mixing(g, tgap):
@cache_result
def get_hgap(g):
g = GraphView(g, directed=False)
remove_parallel_edges(g)
l = label_parallel_edges(g, mark_only=True)
if l.fa.max() > 0:
l.a = numpy.logical_not(l.a)
g = GraphView(g, efilt=l)
else:
del l
T = hashimoto(g, compact=True, operator=True)
try:
ew = scipy.sparse.linalg.eigs(T, k=1, which="LR", return_eigenvectors=False)
except TypeError:
except (TypeError, scipy.sparse.linalg.eigen.arpack.ArpackNoConvergence):
return numpy.nan
finally:
g.clear()
return float(ew.real[0])
@register("diameter", "(Pseudo-) diameter")
@register("diameter", "(Pseudo-) diameter", "log")
@cache_result
def get_diameter(g):
g = GraphView(g, directed=False)
......@@ -255,7 +268,7 @@ def get_vprops(g):
return vprops
@register("pos")
@restrict(N=10000000, exclude=["openstreetmap"])
@restrict(N=1000000, exclude=["openstreetmap"])
@cache_result
def get_pos(g):
if g.num_vertices() < 1000:
......
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