igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Representation of Bipartite Networks


From: Gábor Csárdi
Subject: Re: [igraph] Representation of Bipartite Networks
Date: Mon, 8 Mar 2010 21:57:20 +0100

On Mon, Mar 8, 2010 at 6:14 PM, Lorenzo Isella <address@hidden> wrote:
>>
[...]
> Hi Gabor,
> Well, let us say that I have a bipartite network, where I have nodes of two
> colors (blue and red): I would like to have e.g. all the red nodes on the
> left (possibly in a column) and all the blue nodes on the right.
> See below an example with the fruchterman-reingold layout (which clearly is
> not what I want).
> Any idea of how to get the job done?

Well, putting the (say) red nodes on the left and the blue ones on the
right is easy, but ordering them to minimize edge crossings is not
that easy.

> On top of that: where do I find a list
> of all the different vertex shapes available in igraph?

?igraph.plotting and search for 'shape'

Gabor

> Many thanks
>
> Lorenzo
>
> library(igraph)
> library(Cairo)
>
>
>
> set.seed(1234)
>
>
> nodes_1 <- round(runif(min=1000,max=1020, 200))
> nodes_2 <- round(runif(min=2000,max=2020, 200))
>
> tab <- cbind(as.data.frame(nodes_1), as.data.frame(nodes_2))
>
> g <- graph.data.frame(as.data.frame(tab), dir=FALSE)
>
> g <- simplify(g)
>
> sel_1 <- which(as.numeric(V(g)$name)>=1000 & as.numeric(V(g)$name)<2000)
>
> sel_2 <- which(as.numeric(V(g)$name)>=2000)
>
> V(g)[sel_1-1]$color <- "red"
> V(g)[sel_2-1]$color <- "blue"
>
>
> l <- layout.fruchterman.reingold(g)
> l <- layout.norm(l, -1,1, -1,1)
>
>
> CairoPDF("bipartite_network.pdf")
>
> plot(g, layout=l,
>    vertex.label.dist=0.5,vertex.shape="rectangle",
>    vertex.frame.color="#ff000033", edge.color="#55555533",vertex.label=NA,
> vertex.size=4
>    )
> dev.off()
>
>
>
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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