Commit 2051859d authored by Tiago Peixoto's avatar Tiago Peixoto

Small pylint cleanups

parent 13d4f7bc
......@@ -69,10 +69,10 @@ Classes
"""
__author__="Tiago de Paula Peixoto <tiago@forked.de>"
__copyright__="Copyright 2008 Tiago de Paula Peixoto"
__license__="GPL version 3 or above"
__URL__="http://graph-tool.forked.de"
__author__ = "Tiago de Paula Peixoto <tiago@forked.de>"
__copyright__ = "Copyright 2007-2010 Tiago de Paula Peixoto"
__license__ = "GPL version 3 or above"
__URL__ = "http://graph-tool.forked.de"
# import numpy and scipy before everything to avoid weird segmentation faults
# depending on the order things are imported.
......@@ -89,5 +89,5 @@ from . core import __version__, Graph, Vector_bool, Vector_int32_t, \
__all__ = ["Graph", "Vertex", "Edge", "Vector_bool", "Vector_int32_t",
"Vector_int64_t", "Vector_double", "Vector_long_double",
"Vector_string", "value_types", "load_graph", "PropertyMap",
"group_vector_property", "ungroup_vector_property",
"show_config"]
"group_vector_property", "ungroup_vector_property", "show_config",
"__author__", "__copyright__", "__URL__", "__version__"]
......@@ -22,11 +22,6 @@
Utility module which includes all the sub-modules in graph_tool
"""
__author__="Tiago de Paula Peixoto <tiago@forked.de>"
__copyright__="Copyright 2008 Tiago de Paula Peixoto"
__license__="GPL version 3 or above"
__URL__="http://graph-tool.forked.de"
from graph_tool import *
import graph_tool
from graph_tool.correlations import *
......
......@@ -44,11 +44,13 @@ from .. dl_import import dl_import
dl_import("import libgraph_tool_centrality")
from .. core import _prop
import sys, numpy
import sys
import numpy
__all__ = ["pagerank", "betweenness", "central_point_dominance", "eigentrust",
"absolute_trust"]
def pagerank(g, damping=0.8, prop=None, epslon=1e-6, max_iter=None,
ret_iter=False):
r"""
......@@ -145,6 +147,7 @@ def pagerank(g, damping=0.8, prop=None, epslon=1e-6, max_iter=None,
else:
return prop
def betweenness(g, vprop=None, eprop=None, weight=None, norm=True):
r"""
Calculate the betweenness centrality for each vertex and edge.
......@@ -241,6 +244,7 @@ def betweenness(g, vprop=None, eprop=None, weight=None, norm=True):
_prop("e", g, eprop), _prop("v", g, vprop), norm)
return vprop, eprop
def central_point_dominance(g, betweenness):
r"""
Calculate the central point dominance of the graph, given the betweenness
......@@ -408,7 +412,8 @@ def eigentrust(g, trust_map, vprop=None, norm=False, epslon=1e-6, max_iter=0,
else:
return vprop
def absolute_trust(g, trust_map, source, target = None, vprop=None):
def absolute_trust(g, trust_map, source, target=None, vprop=None):
r"""
Calculate the absolute trust centrality of each vertex in the graph, from a
given source.
......@@ -513,4 +518,3 @@ def absolute_trust(g, trust_map, source, target = None, vprop=None):
if target != -1:
return vprop.a[target]
return vprop
......@@ -57,6 +57,7 @@ import sys
__all__ = ["local_clustering", "global_clustering", "extended_clustering",
"motifs", "motif_significance"]
def local_clustering(g, prop=None, undirected=False):
r"""
Return the local clustering coefficients for all vertices.
......@@ -136,6 +137,7 @@ def local_clustering(g, prop=None, undirected=False):
g.set_directed(True)
return prop
def global_clustering(g):
r"""
Return the global clustering coefficient.
......@@ -187,6 +189,7 @@ def global_clustering(g):
c =_gt.global_clustering(g._Graph__graph)
return c
def extended_clustering(g, props=None, max_depth=3, undirected=False):
r"""
Return the extended clustering coefficients for all vertices.
......@@ -359,7 +362,7 @@ def motifs(g, k, p=1.0, motif_list=None, undirected=None):
sub_list.append(m._Graph__graph)
if type(p) == float:
pd = [1.0]*(k-1)
pd = [1.0] * (k-1)
pd.append(p)
if type(p) == list:
pd = [float(x) for x in p]
......@@ -386,37 +389,39 @@ def motifs(g, k, p=1.0, motif_list=None, undirected=None):
list_hist = zip(sub_list, hist)
# sort according to in-degree sequence
list_hist.sort(lambda x,y: cmp(sorted([v.in_degree() for v in x[0].vertices()]),
sorted([v.in_degree() for v in y[0].vertices()])))
list_hist.sort(lambda x, y: cmp(sorted([v.in_degree() for v in x[0].vertices()]),
sorted([v.in_degree() for v in y[0].vertices()])))
# sort according to out-degree sequence
list_hist.sort(lambda x,y: cmp(sorted([v.out_degree() for v in x[0].vertices()]),
sorted([v.out_degree() for v in y[0].vertices()])))
list_hist.sort(lambda x, y: cmp(sorted([v.out_degree() for v in x[0].vertices()]),
sorted([v.out_degree() for v in y[0].vertices()])))
# sort according to ascending number of edges
list_hist.sort(lambda x,y: cmp(x[0].num_edges(), y[0].num_edges()))
list_hist.sort(lambda x, y: cmp(x[0].num_edges(), y[0].num_edges()))
sub_list = [x[0] for x in list_hist]
hist = [x[1] for x in list_hist]
return sub_list, hist
def _graph_sig(g):
"""return the graph signature, i.e., the in and out degree distribution as
concatenated as a tuple."""
bins = range(0, g.num_vertices()+1)
in_dist = vertex_hist(g, "in", bins = bins if g.is_directed() else [0],
bins = range(0, g.num_vertices() + 1)
in_dist = vertex_hist(g, "in", bins=bins if g.is_directed() else [0],
float_count=False)
out_dist = vertex_hist(g, "out", bins = bins, float_count=False)
sig = tuple([(in_dist[1][i],in_dist[0][i]) for \
out_dist = vertex_hist(g, "out", bins=bins, float_count=False)
sig = tuple([(in_dist[1][i], in_dist[0][i]) for \
i in xrange(len(in_dist[0]))] +
[(out_dist[1][i],out_dist[0][i]) for\
[(out_dist[1][i], out_dist[0][i]) for\
i in xrange(len(out_dist[0]))])
return sig
def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
threshold=0, undirected=None, self_loops=False,
parallel_edges=False, full_output=False,
parallel_edges = False, full_output = False,
shuffle_strategy= "uncorrelated"):
r"""
Obtain the motif significance profile, for subgraphs with k vertices. A
......@@ -510,8 +515,8 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
s_ms, counts = zip(*[x for x in zip(s_ms, counts) if x[1] > threshold])
s_ms = list(s_ms)
counts = list(counts)
s_counts = [0]*len(s_ms)
s_dev = [0]*len(s_ms)
s_counts = [0] * len(s_ms)
s_dev = [0] * len(s_ms)
# group subgraphs by number of edges
m_e = defaultdict(lambda: [])
......@@ -533,37 +538,37 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
if isomorphism(s_ms[l], m_temp[j]):
found = True
s_counts[l] += count_temp[j]
s_dev[l] += count_temp[j]**2
s_dev[l] += count_temp[j] ** 2
if not found:
s_ms.append(m_temp[j])
s_counts.append(count_temp[j])
s_dev.append(count_temp[j]**2)
s_dev.append(count_temp[j] ** 2)
counts.append(0)
m_e[_graph_sig(m_temp[j])].append(len(s_ms)-1)
m_e[_graph_sig(m_temp[j])].append(len(s_ms) - 1)
s_counts = [ x/float(n_shuffles) for x in s_counts ]
s_dev = [ max(sqrt(x[0]/float(n_shuffles) - x[1]**2),1) \
for x in izip(s_dev,s_counts) ]
s_counts = [x / float(n_shuffles) for x in s_counts]
s_dev = [max(sqrt(x[0] / float(n_shuffles) - x[1] ** 2), 1) \
for x in izip(s_dev, s_counts)]
list_hist = zip(s_ms, s_counts, s_dev)
# sort according to in-degree sequence
list_hist.sort(lambda x,y: cmp(sorted([v.in_degree()\
for v in x[0].vertices()]),
sorted([v.in_degree()\
for v in y[0].vertices()])))
list_hist.sort(lambda x, y: cmp(sorted([v.in_degree()\
for v in x[0].vertices()]),
sorted([v.in_degree()\
for v in y[0].vertices()])))
# sort according to out-degree sequence
list_hist.sort(lambda x,y: cmp(sorted([v.out_degree()\
for v in x[0].vertices()]),
sorted([v.out_degree()\
for v in y[0].vertices()])))
list_hist.sort(lambda x, y: cmp(sorted([v.out_degree()\
for v in x[0].vertices()]),
sorted([v.out_degree()\
for v in y[0].vertices()])))
# sort according to ascending number of edges
list_hist.sort(lambda x,y: cmp(x[0].num_edges(), y[0].num_edges()))
list_hist.sort(lambda x, y: cmp(x[0].num_edges(), y[0].num_edges()))
s_ms, s_counts, s_dev = zip(*list_hist)
zscore = [(x[0] - x[1])/x[2] for x in izip(counts, s_counts, s_dev)]
zscore = [(x[0] - x[1]) / x[2] for x in izip(counts, s_counts, s_dev)]
if full_output:
return s_ms, zscore, counts, s_counts, s_dev
......
......@@ -43,12 +43,13 @@ from .. dl_import import dl_import
dl_import("import libgraph_tool_community")
from .. core import _degree, _prop, Graph, libcore
import random, sys
import random
import sys
__all__ = ["community_structure", "modularity", "condensation_graph"]
def community_structure(g, n_iter, n_spins, gamma=1.0, corr= "erdos",
def community_structure(g, n_iter, n_spins, gamma=1.0, corr="erdos",
spins=None, weight=None, t_range=(100.0, 0.01),
verbose=False, history_file=None):
r"""
......@@ -273,6 +274,7 @@ def modularity(g, prop, weight=None):
_prop("v", g, prop))
return m
def condensation_graph(g, prop, weight=None):
r"""
Obtain the condensation graph, where each vertex with the same 'prop' value
......@@ -343,4 +345,3 @@ def condensation_graph(g, prop, weight=None):
_prop("e", g, ecount),
_prop("e", g, weight))
return gp, vcount, ecount
This diff is collapsed.
......@@ -286,7 +286,8 @@ def corr_hist(g, deg_source, deg_target, bins=[[1], [1]], weight=None,
return [array(ret[0], dtype="float64") if float_count else ret[0],
[ret[1][0], ret[1][1]]]
def combined_corr_hist(g, deg1, deg2, bins=[[1],[1]], float_count=True):
def combined_corr_hist(g, deg1, deg2, bins=None, float_count=True):
r"""
Obtain the single-vertex combined correlation histogram for the given graph.
......@@ -361,6 +362,8 @@ def combined_corr_hist(g, deg1, deg2, bins=[[1],[1]], float_count=True):
Combined in/out-degree correlation histogram.
"""
if bins == None:
bins = [[1], [1]]
ret = libgraph_tool_correlations.\
vertex_combined_correlation_histogram(g._Graph__graph,
_degree(g, deg1),
......@@ -369,7 +372,8 @@ def combined_corr_hist(g, deg1, deg2, bins=[[1],[1]], float_count=True):
return [array(ret[0], dtype="float64") if float_count else ret[0],
[ret[1][0], ret[1][1]]]
def avg_neighbour_corr(g, deg_source, deg_target, bins=[1], weight=None):
def avg_neighbour_corr(g, deg_source, deg_target, bins=None, weight=None):
r"""
Obtain the average neighbour-neighbour correlation for the given graph.
......@@ -448,13 +452,15 @@ def avg_neighbour_corr(g, deg_source, deg_target, bins=[1], weight=None):
Average out/out degree correlation.
"""
if bins == None:
bins = [1]
ret = libgraph_tool_correlations.\
vertex_avg_correlation(g._Graph__graph, _degree(g, deg_source),
_degree(g, deg_target), _prop("e", g, weight),
bins)
return [ret[0], ret[1], ret[2][0]]
def avg_combined_corr(g, deg1, deg2, bins=[1]):
def avg_combined_corr(g, deg1, deg2, bins=None):
r"""
Obtain the single-vertex combined correlation histogram for the given graph.
......@@ -524,6 +530,8 @@ def avg_combined_corr(g, deg1, deg2, bins=[1]):
Average combined in/out-degree correlation.
"""
if bins == None:
bins = [1]
ret = libgraph_tool_correlations.\
vertex_avg_combined_correlation(g._Graph__graph, _degree(g, deg1),
_degree(g, deg2), bins)
......
......@@ -21,18 +21,19 @@
Some useful decorators
"""
__author__="Tiago de Paula Peixoto <tiago@forked.de>"
__copyright__="Copyright 2008 Tiago de Paula Peixoto"
__license__="GPL version 3 or above"
__author__ = "Tiago de Paula Peixoto <tiago@forked.de>"
__copyright__ = "Copyright 2008 Tiago de Paula Peixoto"
__license__ = "GPL version 3 or above"
import inspect, functools
import libgraph_tool_core as libcore
import inspect
import functools
################################################################################
# Decorators
# Some useful function decorators which will be used
################################################################################
def _wraps(func):
"""This decorator works like the functools.wraps meta-decorator, but
also preserves the function's argument signature. This uses eval, and is
......@@ -46,6 +47,7 @@ def _wraps(func):
return functools.wraps(func)(wrap)
return decorate
def _attrs(**kwds):
"""Decorator which adds arbitrary attributes to methods"""
def decorate(f):
......@@ -54,6 +56,7 @@ def _attrs(**kwds):
return f
return decorate
def _limit_args(allowed_vals):
"""Decorator which will limit the values of given arguments to a specified
list of allowed values, and raise TypeError exception if the given value
......@@ -66,7 +69,7 @@ def _limit_args(allowed_vals):
arguments = zip(arg_names, args)
arguments += [(k, kwargs[k]) for k in kwargs.keys()]
for a in arguments:
if allowed_vals.has_key(a[0]):
if a[0] in allowed_vals:
if a[1] not in allowed_vals[a[0]]:
raise TypeError("value for '%s' must be one of: %s" % \
(a[0], ", ".join(allowed_vals[a[0]])))
......@@ -74,13 +77,14 @@ def _limit_args(allowed_vals):
return wrap
return decorate
def _require(arg_name, *allowed_types):
"""Decorator that lets you annotate function definitions with argument type
requirements. These type requirements are automatically checked by the
system at function invocation time."""
def make_wrapper(f):
if hasattr(f, "wrapped_args"):
wrapped_args = getattr(f, "wrapped_args")
wrapped_args = f.wrapped_args
else:
code = f.func_code
wrapped_args = list(code.co_varnames[:code.co_argcount])
......@@ -88,7 +92,7 @@ def _require(arg_name, *allowed_types):
try:
arg_index = wrapped_args.index(arg_name)
except ValueError:
raise NameError, arg_name
raise NameError(arg_name)
@_wraps(f)
def wrapper(*args, **kwargs):
......@@ -97,8 +101,8 @@ def _require(arg_name, *allowed_types):
if not isinstance(arg, allowed_types):
type_list = " or ".join(str(allowed_type) \
for allowed_type in allowed_types)
raise TypeError, "Expected '%s' to be %s; was %s." % \
(arg_name, type_list, type(arg))
raise TypeError("Expected '%s' to be %s; was %s." % \
(arg_name, type_list, type(arg)))
else:
if arg_name in kwargs:
arg = kwargs[arg_name]
......@@ -106,8 +110,8 @@ def _require(arg_name, *allowed_types):
type_list = " or ".join(str(allowed_type) \
for allowed_type in \
allowed_types)
raise TypeError, "Expected '%s' to be %s; was %s." %\
(arg_name, type_list, type(arg))
raise TypeError("Expected '%s' to be %s; was %s." %\
(arg_name, type_list, type(arg)))
return f(*args, **kwargs)
wrapper.wrapped_args = wrapped_args
......
......@@ -28,6 +28,7 @@ except ImportError:
all = ["dl_import"]
def dl_import(import_expr):
"""Import module according to import_expr, but with RTLD_GLOBAL enabled."""
# we need to get the locals and globals of the _calling_ function. Thus, we
......@@ -39,13 +40,13 @@ def dl_import(import_expr):
# RTLD_GLOBAL needs to be set in dlopen() if we want typeinfo and friends to
# work properly across DSO boundaries. See http://gcc.gnu.org/faq.html#dso
# The "except" is because the dl module raises a system error on ia64 and x86_64
# systems because "int" and addresses are different sizes.
# The "except" is because the dl module raises a system error on ia64 and
# x86_64 systems because "int" and addresses are different sizes.
orig_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_LAZY|RTLD_GLOBAL)
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL)
exec import_expr in local_dict, global_dict
sys.setdlopenflags(orig_dlopen_flags) # reset it to normal case to avoid
# unnecessary symbol collision
sys.setdlopenflags(orig_dlopen_flags) # reset it to normal case to avoid
# unnecessary symbol collision
......@@ -62,12 +62,13 @@ except ImportError:
__all__ = ["graph_draw", "arf_layout", "random_layout"]
def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
maxiter=None, ratio= "fill", overlap="prism", sep=None,
def graph_draw(g, pos=None, size=(15, 15), pin=False, layout="neato",
maxiter=None, ratio="fill", overlap="prism", sep=None,
splines=False, vsize=0.1, penwidth=1.0, elen=None, gprops={},
vprops={}, eprops={}, vcolor=None, ecolor=None,
vcmap=matplotlib.cm.jet, vnorm=True, ecmap=matplotlib.cm.jet,
enorm=True, output= "", output_format= "auto", returngv=False,
enorm=True, output="", output_format="auto", returngv=False,
fork=False, return_bitmap=False, seed=0):
r"""Draw a graph using graphviz.
......@@ -290,28 +291,29 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
penwidth = s
# main graph properties
gv.setv(gvg,"outputorder", "edgesfirst")
gv.setv(gvg,"mode", "major")
gv.setv(gvg, "outputorder", "edgesfirst")
gv.setv(gvg, "mode", "major")
if overlap == False:
overlap = "false"
else:
overlap = "true"
if isinstance(overlap,str):
gv.setv(gvg,"overlap", overlap)
if isinstance(overlap, str):
gv.setv(gvg, "overlap", overlap)
if sep != None:
gv.setv(gvg,"sep", str(sep))
gv.setv(gvg, "sep", str(sep))
if splines:
gv.setv(gvg,"splines", "true")
gv.setv(gvg,"ratio", str(ratio))
gv.setv(gvg,"size", "%f,%f" % (size[0]/2.54,size[1]/2.54)) # centimeters
gv.setv(gvg, "splines", "true")
gv.setv(gvg, "ratio", str(ratio))
# size is in centimeters... convert to inches
gv.setv(gvg, "size", "%f,%f" % (size[0] / 2.54, size[1] / 2.54))
if maxiter != None:
gv.setv(gvg,"maxiter", str(maxiter))
gv.setv(gvg, "maxiter", str(maxiter))
seed = numpy.random.randint(sys.maxint)
gv.setv(gvg, "start", "%d" % seed)
# apply all user supplied properties
for k,val in gprops.iteritems():
for k, val in gprops.iteritems():
if isinstance(val, PropertyMap):
gv.setv(gvg, k, str(val[g]))
else:
......@@ -322,8 +324,8 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
minmax = [float("inf"), -float("inf")]
for v in g.vertices():
c = vcolor[v]
minmax[0] = min(c,minmax[0])
minmax[1] = max(c,minmax[1])
minmax[0] = min(c, minmax[0])
minmax[1] = max(c, minmax[1])
if minmax[0] == minmax[1]:
minmax[1] += 1
if vnorm:
......@@ -335,8 +337,8 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
minmax = [float("inf"), -float("inf")]
for e in g.edges():
c = ecolor[e]
minmax[0] = min(c,minmax[0])
minmax[1] = max(c,minmax[1])
minmax[0] = min(c, minmax[0])
minmax[1] = max(c, minmax[1])
if minmax[0] == minmax[1]:
minmax[1] += 1
if enorm:
......@@ -345,11 +347,10 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
enorm = lambda x: x
nodes = {}
edges = []
# add nodes
for v in g.vertices():
n = gv.node(gvg,str(g.vertex_index[v]))
n = gv.node(gvg, str(g.vertex_index[v]))
if type(vsize) == PropertyMap:
vw = vh = vsize[v]
......@@ -362,10 +363,10 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
gv.setv(n, "color", "black")
# apply color
if vcolor != None:
if isinstance(vcolor,str):
if isinstance(vcolor, str):
gv.setv(n, "fillcolor", vcolor)
else:
color = tuple([int(c*255.0) for c in vcmap(vnorm(vcolor[v]))])
color = tuple([int(c * 255.0) for c in vcmap(vnorm(vcolor[v]))])
gv.setv(n, "fillcolor", "#%.2x%.2x%.2x%.2x" % color)
else:
gv.setv(n, "fillcolor", "red")
......@@ -373,11 +374,11 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
# user supplied position
if pos != None:
gv.setv(n, "pos", "%f,%f" % (pos[0][v],pos[1][v]))
gv.setv(n, "pos", "%f,%f" % (pos[0][v], pos[1][v]))
gv.setv(n, "pin", str(pin))
# apply all user supplied properties
for k,val in vprops.iteritems():
for k, val in vprops.iteritems():
if isinstance(val, PropertyMap):
gv.setv(n, k, str(val[v]))
else:
......@@ -393,10 +394,10 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
# apply color
if ecolor != None:
if isinstance(ecolor,str):
if isinstance(ecolor, str):
gv.setv(ge, "color", ecolor)
else:
color = tuple([int(c*255.0) for c in ecmap(enorm(ecolor[e]))])
color = tuple([int(c * 255.0) for c in ecmap(enorm(ecolor[e]))])
gv.setv(ge, "color", "#%.2x%.2x%.2x%.2x" % color)
# apply edge length
......@@ -414,15 +415,14 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
gv.setv(ge, "penwidth", str(penwidth))
# apply all user supplied properties
for k,v in eprops.iteritems():
for k, v in eprops.iteritems():
if isinstance(v, PropertyMap):
gv.setv(ge, k, str(v[e]))
else:
gv.setv(ge, k, str(v))
gv.layout(gvg, layout)
gv.render(gvg, "dot", "/dev/null") # retrieve positions
gv.render(gvg, "dot", "/dev/null") # retrieve positions
if pos == None:
pos = (g.new_vertex_property("double"), g.new_vertex_property("double"))
......@@ -459,7 +459,7 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
pid = os.fork()
if pid == 0:
gv.render(gvg, output_format, output)
os._exit(0) # since we forked, it's good to be sure
os._exit(0) # since we forked, it's good to be sure
if output_format != "xlib":
os.wait()
elif output != None:
......@@ -480,6 +480,7 @@ def graph_draw(g, pos=None, size=(15, 15), pin=False, layout= "neato",
else:
return ret[0]
def random_layout(g, shape=None, pos=None, dim=2):
r"""Performs a random layout of the graph.
......@@ -512,17 +513,18 @@ def random_layout(g, shape=None, pos=None, dim=2):
pos = ungroup_vector_property(pos)
if shape == None:
shape = [sqrt(g.num_vertices())]*dim
shape = [sqrt(g.num_vertices())] * dim
for i in xrange(dim):
_check_prop_scalar(pos[i], name="pos[%d]" % i)
_check_prop_writable(pos[i], name="pos[%d]" % i)
a = pos[i].get_array()
a[:] = numpy.random.random(len(a))*shape[i]
a[:] = numpy.random.random(len(a)) * shape[i]
pos = group_vector_property(g, pos)
return pos
def arf_layout(g, weight=None, d=0.1, a=10, dt=0.001, epsilon=1e-6,
max_iter=1000, pos=None, dim=2):
r"""Calculate the ARF spring-block layout of the graph.
......
......@@ -44,6 +44,7 @@ from .. core import _prop, _check_prop_scalar, _check_prop_writable
__all__ = ["edmonds_karp_max_flow", "push_relabel_max_flow",