[Top][All Lists]

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

[igraph] How to preserve E(g)

From: MATSUDA, Noriyuki
Subject: [igraph] How to preserve E(g)
Date: Mon, 12 Nov 2007 15:21:56 +0900


  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)
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
g <- add.edges(g,c(0,1,2,7,15,25),color="red")

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> 松 田 紀 之

reply via email to

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