def get_reusable_springlayout(network,seed=0):
"""returns a networkx spring layout function with deterministic behaviour
(useful to draw a series of thumbnails)"""
rng = RandomState(seed)
nodelist = network.nodes()
initpos = dict(zip(nodelist,rng.rand(len(nodelist),2)))
return lambda net:nx.spring_layout(net,pos=initpos)
评论列表
文章目录