[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] degree distribution for bipartite network

**From**: |
Simone Gabbriellini |

**Subject**: |
Re: [igraph] degree distribution for bipartite network |

**Date**: |
Thu, 3 Feb 2011 19:44:55 +0100 |

Tamas,
thanks very much, it really helped me out!
best,
simo
Il giorno 03/feb/2011, alle ore 18.05, Tamas Nepusz ha scritto:
>* *
>*> 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:*
>* *
>* g.vs.select(type=0).degree()*
>* *
>* 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.*
>* *
>* -- *
>* T.*
>* *
>* *
>* _______________________________________________*
>* igraph-help mailing list*
>* address@hidden*
>* http://lists.nongnu.org/mailman/listinfo/igraph-help*