[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Translate code from r to python

From: Tamas Nepusz
Subject: Re: [igraph] Translate code from r to python
Date: Fri, 26 Jun 2009 12:19:48 +0100

g.sw=rewire.edges(graph.lattice(vcount(g), nei=mean(degree(g)), dir=TRUE, mutual=TRUE), p=0.25)
g_sw = Graph.Lattice(g.vcount(), nei=sum(g.degree())/g.vcount(), dir=True, mutual=True)
g_sw.rewire(0.25 * g_sw.ecount())

Note that rewire() does not have a p= argument in Python, only n=... which lets you specify the number of rewirings. That's why I've written g_sw.ecount() * 0.25. Another difference is that Graph.rewire() rewires the graph in-place in Python, so you must construct the graph first and then invoke its rewire() method.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]