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: Lorenzo Isella
Subject: Re: [igraph] Representation of Bipartite Networks
Date: Mon, 08 Mar 2010 18:14:39 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)


Date: Sat, 6 Mar 2010 00:42:37 +0100 From: G?bor Cs?rdi <address@hidden> Subject: Re: [igraph] Representation of Bipartite Networks To: Help for igraph users <address@hidden> Message-ID: <address@hidden> Content-Type: text/plain; charset=ISO-8859-1 Lorenzo, I don't know what is recommended. We don't have any special layout algorithms for bipartite networks, AFAIK. Maybe it is possible to work out something meaningful using positive and negative edge weights in the Fruchterman-Reingold algorithm. My idea would be to create the union of the original and a full graph. In the full graph, vertices of different type would repulse each other (negative weight on the edge) and vertices of the same type would attract each other. Whether this gives anything meaningful, I have no idea. Maybe it is enough to simply use different vertex shapes for both vertex types. Best, Gabor On Fri, Mar 5, 2010 at 3:57 PM, Lorenzo Isella <address@hidden> wrote:
> Dear All,
> I am actually dealing with bipartite networks.
> What is the best way (if there is any) to plot a bipartite network?
> Is there any recommended layout in igraph?
> Cheers
>
> Lorenzo
>

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? On top of that: where do I find a list of all the different vertex shapes available in igraph?
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()







reply via email to

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