[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] Calculation of Coordination Number

**From**: |
Tamas Nepusz |

**Subject**: |
Re: [igraph] Calculation of Coordination Number |

**Date**: |
Wed, 13 Feb 2008 10:47:50 +0100 |

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.