Reputation: 33
I'm trying to color only self-loop edges in my igraph network. Here is the sample of my data.
head(network.txt)
From To
A A
A B
A C
A D
B A
B B
B C
B D
C A
C B
C C
C D
D A
D B
D C
D D
Here is the network code
df=read.table("network.txt", header = TRUE)
nodes=unique(df$From)
g=graph_from_data_frame(df)
plot(g, edge.arrow.size=0.2, vertex.color="gold", vertex.size=15, vertex.frame.color="gray", vertex.label.color="black", vertex.label.cex
=0.5, vertex.label.dist=0, edge.curved=0.2, edge.color="black", main="Adult CRC network", layout=layout_in_circle)
and
> head(E(g))
+ 6/16 edges from ea19d0a (vertex names):
[1] A->A A->B A->C A->D B->A B->B
Also, is there anyway to keep the loops outside of the network?
Upvotes: 3
Views: 454
Reputation: 54247
You could do it like this:
library(igraph)
g <- make_full_graph(10, loops = TRUE)
plot(g, edge.color = ifelse(is.loop(g), "red", "grey"))
Upvotes: 4