[Top][All Lists]

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

Re: [igraph] Calculation of Coordination Number

From: Lorenzo Isella
Subject: Re: [igraph] Calculation of Coordination Number
Date: Sun, 17 Feb 2008 19:13:07 +0100
User-agent: Mozilla-Thunderbird (X11/20080110)

Thanks for your answers and sorry for the late reply.
One final question: since I deal with rather large adjacency matrices, I need 
to be efficient when working out the quantities of interest.
For instance, starting from the adjacency matrix, I first work out the 
connected components, then I would like to evaluate the mean degree (thanks for 
fixing my jargon) within each set of connected components.
What is the most efficient way of doing this, without re-writing the adjacency 
matrix for the components I already know to be connected and re-calculating 
various properties I know already plus the mean degree?


Message: 15
Date: Wed, 13 Feb 2008 10:47:50 +0100
From: Tamas Nepusz <address@hidden>
Subject: Re: [igraph] Calculation of Coordination Number
To: Help for igraph users <address@hidden>
Message-ID: <address@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

> Lorenzo,
> if your graph is `g` then
>    degree(g)
> gives the number of direct neighbors of each vertex (or particle).
Just to translate it to Python: g.degree() gives the number of direct neighbors of each vertex. If your graph is directed, you may only want to count only the outgoing or the incoming edges: g.degree(igraph.OUT) or g.degree(igraph.IN)

> So
>    mean(degree(g))
In Python: sum(g.degree()) / float(g.vcount())

> (and to turn an adjacency matrix `am` into an igraph object `g` just > use "g <- graph.adjacency(am)")
In Python: g = Graph.Adjacency(matrix)
e.g. g = Graph.Adjacency([[0,1,0],[1,0,1],[0,1,0]])

-- T.

reply via email to

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