igraph-help
[Top][All Lists]
Advanced

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

[igraph] Re: weighted bipartite graphs


From: Uri Shwed
Subject: [igraph] Re: weighted bipartite graphs
Date: Sun, 29 Nov 2009 13:35:19 -0500

Dear Gabor, 
Thanks so much, this LOOKS perfect - but I can't get it to work!
I have several problems:
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.
2) I tried downloading igraph again (by simply calling install.pacgages("igraph") and didn't get the support for "multiplicity".
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.
I'm probably just doing something very basic very wrong. Any idea what?
Thanks so much,
Uri
On Nov 29, 2009, at 12:01 PM, address@hidden wrote:

Message: 9
Date: Sun, 29 Nov 2009 17:30:40 +0100
From: G?bor Cs?rdi <address@hidden>
Subject: Re: [igraph] Weighted bipartite graphs?
To: Help for igraph users <address@hidden>
Message-ID:
<address@hidden>
Content-Type: text/plain; charset=ISO-8859-1

OK, I added support for keeping the "multiplicity" information of the
edges, this is done automatically:

print(proj[[2]], e=T)
Vertices: 8
Edges: 19
Directed: FALSE
Edges and their attributes:
                 weight
[0]  'P1' -- 'P2'      1
[1]  'P1' -- 'P3'      1
[2]  'P1' -- 'P4'      1
[3]  'P1' -- 'P5'      2
[4]  'P1' -- 'P6'      1
[5]  'P1' -- 'P7'      1
[6]  'P1' -- 'P8'      1
[7]  'P2' -- 'P3'      1
[8]  'P2' -- 'P4'      1
[9]  'P2' -- 'P5'      1
[10] 'P3' -- 'P4'      1
[11] 'P3' -- 'P5'      1
[12] 'P4' -- 'P5'      1
[13] 'P5' -- 'P6'      1
[14] 'P5' -- 'P7'      1
[15] 'P5' -- 'P8'      1
[16] 'P6' -- 'P7'      1
[17] 'P6' -- 'P8'      1
[18] 'P7' -- 'P8'      1

Best,
Gabor

On Sun, Nov 29, 2009 at 2:50 PM, Gábor Csárdi <address@hidden> wrote:
Dear Uri,

On Mon, Nov 23, 2009 at 9:27 PM, Uri Shwed <address@hidden> wrote:
Dear Gabor et.al.,
What would you guys say is the best way to get a bipartite data set with
meta-data into a weighted projection?
For example:

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))

desired outcome:
The first graph projection below (achieved through graph.incidence and
bipartite.projection), with Edge attribute of weight (giving all edges
weight of 1 and the edge between 1 and 5 a weight of 2, because they
attended 2 events together), and an edge attribute of year.
Any ideas?

I am not sure what you did with graph.incidence, but this is what I would do.

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
*******************************************


reply via email to

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