|
From: | Tamas Nepusz |
Subject: | Re: [igraph] Translate code from r to python |
Date: | Mon, 29 Jun 2009 07:49:42 +0100 |
Hi Simone,
Well, it depends on what you want to do. Graph.Lattice([1, g.vcount()]) practically generates a 1-dimensional lattice (a path, or a circle if you specify mutual=True). The first argument of Graph.Lattice describes the size of the lattice along each dimension. If you want to make a roughly 2D square lattice, you have to take the square root of g.vcount() and use that twice: [int(g.vcount()**0.5), int(g.vcount()**0.5)]. Note that the number of vertices will match g.vcount() only approximately if g.vcount()**0.5 is not an integer itself. If you are aiming for something like Watts and Strogatz have done in their original paper, then go for a 1-dimensional, mutual, circular lattice. See help(Graph.Lattice) for more information.TypeError: argument 1 must be list, not int WARNING: Failure executing file: <analisi_venezia.py> is this a correct solution?g_sw = Graph.Lattice([1, g.vcount()], nei=sum(g.degree())/ g.vcount(), dir=True, mutual=True)
If I understand the rewire procedure correctly, it changes in this case the 25% of the edges in the graph.More precisely: it makes 0.25*g.ecount() rewire attempts, preserving the degree distribution, but it does not guarantee that 0.25*g.ecount() _unique_ edges will be rewired. Some edges might be rewired twice or more.
How can it be that the average path after the rewire is longer than in the regular lattice???Is it a directed or an undirected lattice? If directed, it can happen easily: rewiring some of the edges almost surely breaks the reciprocal edge pairs by moving only _one_ of the edges. If the being moved went originally from A to B, then the shortest path from A to B may have increased from 1.
By the way, if you only need the average path length, you can simply use g.average_path_length().
-- Tamas
[Prev in Thread] | Current Thread | [Next in Thread] |