[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] subgraph and plot
From: |
simone gabbriellini |
Subject: |
[igraph] subgraph and plot |
Date: |
Sun, 5 Apr 2009 11:42:38 +0200 |
Hi List,
I am trying to plot a graph with grey vertices and then to color some
of them with different colors, due to core/periphery structure I found
with Ucinet... (btw, how could it be wonderful to have a core/
periphery function in igraph... :)
this is the code I use:
g <- read.graph(nomefile, format="graphml")
g <- delete.vertices(g, which(degree(g)==0)-1)
g<-simplify(g)
#
ll<-layout.fruchterman.reingold(g, weights=E(g)$weigths)
ll<-layout.norm(ll,-1,1,-1,1)
#
plot(g, layout=ll, vertex.size=5, vertex.label=V(g)$id,
vertex.label.dist=0.4,
vertex.label.cex=0.4, vertex.color="grey", vertex.label.color="black",
vertex.frame.color="black", edge.color="lightgrey",
edge.arrow.size=0.3, rescale=FALSE, main="March 2004")
#
#SWG
core<-c("Brenn Tantor", "Kveldersen")
corenumber<-array(length(core))
for (i in 1:length(core)){
corenumber[i]<-V(g)[label==core[i]]
}
g4 <- subgraph(g, corenumber)
g4 <- delete.edges(g4, E(g4))
l4 <- ll[ corenumber+1, ]
plot(g4, layout=l4, vertex.size=5, vertex.label=NA,
vertex.color=NA, vertex.frame.color="blue", add=TRUE, rescale=FALSE)
and it works perfect untill the "core" variable contains at least two
names... if it happens to be only one name, then I am able to
subgraph, to find the layout coordinates of that single node, but when
I try to plot I get this error from layout:
Error in layout[, 1] : wrong number of dimensions
can someone help me?
thanks,
simone
- [igraph] subgraph and plot,
simone gabbriellini <=