igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] graph.data.frame & bipartite graphs


From: Gábor Csárdi
Subject: Re: [igraph] graph.data.frame & bipartite graphs
Date: Wed, 14 Oct 2009 14:06:12 +0200

On Thu, Oct 8, 2009 at 4:02 PM, Yannick Rochat <address@hidden> wrote:
> Dear Gábor and Tamás,
>
> I would like to use the command graph.data.frame to create a bipartite
> graph, but I can't find how to make it recognize two different sets of
> vertices (with different arguments, like actor$age, actor$gender and
> team$country, team$budget …).
>
> Can graph.data.frame deal with bipartite graphs?

No, it cannot.

> If not, do I have to create
> a single data.frame with empty entries like the following one?

Yes, I think so. Unfortunately, you cannot have a vertex attribute
that is defined only for some vertices. One solution to this is to use
NA, just like you did. If you also supply the logical 'type' vertex
attribute, then igraph knows that the graph is bipartite:

actors1 <- data.frame(name=c("Alice", "Bob",
"Cecil"),age=c(48,33,45),country=NA,type=FALSE) #Players
actors2 <- data.frame(name=c("Milan",
"Zurich"),age=NA,country=c("Italy","Switzerland"), type=TRUE) #Teams
actors <- rbind(actors1,actors2)
g <- graph.data.frame(relations, directed=TRUE, vertices=actors)

Best,
G.

> actors1 <- data.frame(name=c("Alice", "Bob",
> "Cecil"),age=c(48,33,45),country=NA) #Players
> actors2 <- data.frame(name=c("Milan",
> "Zurich"),age=NA,country=c("Italy","Switzerland")) #Teams
> relations <- data.frame(from=c("Alice","Alice","Bob","Cecil"),
>                           to=c("Milan","Zurich","Milan","Zurich"))
> actors <- rbind(actors1,actors2)
> g <- graph.data.frame(relations, directed=TRUE, vertices=actors)
> is.bipartite(g) #TRUE
> print(g,v=TRUE)
>
>
> Thanks in advance!
>
> Best,
>
>
> Yannick Rochat - IMA - Université de Lausanne
> http://www.unil.ch/unisciences/YannickRochat
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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