igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to preserve E(g)


From: MATSUDA, Noriyuki
Subject: Re: [igraph] How to preserve E(g)
Date: Mon, 12 Nov 2007 18:28:05 +0900

Thanks a lot, Gabor:

  I've got almost the right solution.  By 'almost', I mean that quotes (")
are not necessary.
I need the matrix in order to visually check the performance of edge.betweenness.
community.

  Thanks again.

At 10:16 AM +0100 07.11.12, Gabor Csardi wrote:
Hmmm, I'm not completely sure what you want to do. If you want to save
the edge list with symbolic vertex names then you can use

get.edgelist(g)

Eg:

cbind(z, eBtw$edge.betweenness,get.edgelist(g)[z+1,])

Note that you need to add 1 to the edge ids to index the matrix.
Is this what you need?

Gabor

On Mon, Nov 12, 2007 at 03:21:56PM +0900, MATSUDA, Noriyuki wrote:
 Hello:

   Given a graph "g", E(g) gives an edge list on the console like
        [0]  4a  -- 0A
        [1]  5a  -- 0A
             .......
       [13] 17b -- 1B
       [14] 18c -- 2C
 How can I keep the result in a variable, say "eg"?
    What I really want to is to construct a matrix to store selected
 information of the edge.betweenness.community for later use.  I'd
 appreciate if some one can rescue me out of trouble shown below:

-----------------------------------------------------------------------------------------------------------
 library(igraph); options(digits=3)
 # Naming vertices by sub-group
 eA<- c(0,4,0,5,0,6,0,7,0,8,0,9,0,10)
 eB<- c(1,11,1,12,1,13,1,14,1,15,1,16,1,17)
 eC<- c(2,18,2,19,2,20,2,21,2,22,2,23,2,24)
 eD<- c(3,25,3,26,3,27,3,28,3,29,3,30,3,31,3,32)
 g<-graph(c(eA,eB,eC,eD),directed=F)
 z <- 0:3;  V(g)[z]$name = paste(V(g)[z],LETTERS[1:4],sep="")
 z <- 4:10; V(g)[z]$name = paste(V(g)[z],"a",sep="")
 z <- 11:17; V(g)[z]$name = paste(V(g)[z],"b",sep="")
 z <- 18:24; V(g)[z]$name = paste(V(g)[z],"c",sep="")
 z <- 25:32; V(g)[z]$name = paste(V(g)[z],"d",sep="")

 V(g)$color="#efefef"; V(g)$size=16
 V(g)[0:3]$color="#aaaaFF"; V(g)[0:3]$size=20
 E(g)$color="black"
 g <- add.edges(g,c(0,1,2,7,15,25),color="red")
 V(g)[c(7,15,25)]$color="#aabb99"

 quartz(width=7,height=7)
 plot(g, layout= layout.fruchterman.reingold.grid,vertex.label=V(g)$name)
 title(main=list("fruchterman.reingold.grid",col="red",font=4,
 cex=1.2)) # 1=plain text, 2=bold face, 3=italic,  4=bold italic,
 5=symbol

 #edge.betweenness.community removes the most outstanding edge, and
 repeats the process.
 #The results are hard to understand after the first removal
 eBtw <- edge.betweenness.community(g,merges=F)
 z <- eBtw$removed.edges
 cbind(z, eBtw$edge.betweenness,E(g)[z])

---------------------------------------------------------------------------------------------------------------

 --
 MATSUDA, Noriyuki <in Kanji> 松 田 紀 之


 _______________________________________________
 igraph-help mailing list
 address@hidden
 http://lists.nongnu.org/mailman/listinfo/igraph-help

--
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help


--
MATSUDA, Noriyuki <in Kanji> 松 田 紀 之




reply via email to

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