|
From: | Uri Shwed |
Subject: | [igraph] Re: Weighted bipartite graphs - edge attributes? |
Date: | Mon, 30 Nov 2009 14:01:23 -0500 |
Dear Gabor, Thank you so much for your comprehensive advise. In the example below, "year" is a property of the event, and people can go to several events. I understand the trick for making vertex attributes in either projection, but how can I make vertex attributes in one projection to register edge attributes in the other projection? Thanks, Uri library(igraph) data<-data.frame(people=c(1:5,5:8,1),events=c(1,1,1,1,1,2,2,2,2,2),year=c(2004,2004,2004,2004,2004,2005,2005,2005,2005,2005)) data2 <- data.frame(people=paste(sep="", "P", data[,1]), events=paste(sep="", "E", data[,2])) G <- graph.data.frame(data2, dir=FALSE) V(G)$type <- grepl("^P", V(G)$name) proj <- bipartite.projection(G) V(proj[[1]])$name <- V(G)$name[!V(G)$type] V(proj[[2]])$name <- V(G)$name[V(G)$type] # We use here that bipartite.projection keeps the order of the vertices # ideally it should keep the vertex attributes Unfortunately, there is no way currently to include the "multiplicity" as edge weight, at least not easily. But this would be a logical extension, so I will add it ASAP. Best, G. $proj1 Vertices: 8 Edges: 19 Directed: FALSE Edges: [0] 0 -- 1 [1] 0 -- 2 [2] 0 -- 3 [3] 0 -- 4 [4] 0 -- 5 [5] 0 -- 6 [6] 0 -- 7 [7] 1 -- 2 [8] 1 -- 3 [9] 1 -- 4 [10] 2 -- 3 [11] 2 -- 4 [12] 3 -- 4 [13] 4 -- 5 [14] 4 -- 6 [15] 4 -- 7 [16] 5 -- 6 [17] 5 -- 7 [18] 6 -- 7 $proj2 Vertices: 2 Edges: 1 Directed: FALSE Edges: e e [0] 0 -- 1 Thanks, Uri _______________________________________________ igraph-help mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/igraph-help -- Gabor Csardi <address@hidden> UNIL DGM -- Gabor Csardi <address@hidden> UNIL DGM ------------------------------ _______________________________________________ igraph-help mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/igraph-help End of igraph-help Digest, Vol 40, Issue 26 ******************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.gnu.org/pipermail/igraph-help/attachments/20091129/cc942374/attachment.html ------------------------------ Message: 2 Date: Sun, 29 Nov 2009 20:39:11 +0100 From: G?bor Cs?rdi <address@hidden> Subject: Re: [igraph] Re: weighted bipartite graphs To: Help for igraph users <address@hidden> Message-ID: <address@hidden> Content-Type: text/plain; charset=ISO-8859-1 Uri, On Sun, Nov 29, 2009 at 7:35 PM, Uri Shwed <address@hidden> wrote: [...] 1) your code generates this response from my system: R(2234,0xa0359500) malloc: *** error for object 0x1ebfdf48: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug (caused by proj<-bipartite.projection(G). It seems to still create proj, and the projections seem right, but without any edge or vertex attributes. I think this is a bug that was corrected in the 0.5.3 version of igraph. 2) I tried downloading igraph again (by simply calling install.pacgages("igraph") and didn't get the support for "multiplicity". Because it was added to the development version of igraph. You can download it from Launchpad, or you can download a snapshot from http://igraph.googlecode.com/files/igraph_nightly_0.6-1704-20091129.tar.gz This is a source R package. 3) I tried adding to data2 the "year" coloumn from data, hoping that it would stick as edge attribute in proj[[2]] or at least as vertex attribute in proj[[1]]. It didn't. bipartite.projection drops the attributes, unfortunately. But it keeps the order of the vertices, so you can use the same trick I used for 'name' to keep vertex attributes. Best, Gabor [...] |
[Prev in Thread] | Current Thread | [Next in Thread] |