[Top][All Lists]

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

Re: [igraph] degree distribution for bipartite network

From: Tamas Nepusz
Subject: Re: [igraph] degree distribution for bipartite network
Date: Thu, 03 Feb 2011 18:05:09 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7

> deg<-degree(g)[V(g)$type==FALSE]
> dd<-as.numeric(table(deg))/sum(as.numeric(table(deg)))
> Is it possible in python to find the degree distribution conditioned on a 
> node's attribute value?
Some of the graph methods that allow a vertex set as the first argument
can also be called like this:


This simply translates to g.degree(g.vs.select(type=0)) and gives you
the degrees of vertices with type zero. You can then do whatever you
want with this list; e.g., feed them to a Histogram object:

degs = g.vs.select(type=0).degree()
hist = Histogram(bin_width=1)
hist << degs

Or, you can simply count the degrees in a dict:

hist = defaultdict(int)
for degree in g.vs.select(type=0).degree():
    hist[degree] += 1

Python does not have built-in classes for histograms/distributions,
unlike R, so you have to do this manually or create a helper function.
Matplotlib can then be used for plotting.


reply via email to

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