[R] coloring edges in IGRAPH
Bogdan Tanasa
t@n@@@ @ending from gm@il@com
Wed Jul 25 02:48:43 CEST 2018
Dear all,
I would appreciate a piece of advice please : I am aiming to color the
edges in a graph, by using IGRAPH package.
It works well for the big braph, however, when I decompose the graph into 2
subgraphs and color code those, the color of the edges change
(unexpectedly).
more precisely, as an example -- we have a dataframe :
el <- data.frame(Partner1=c(1, 3, 4, 5, 6), Partner2=c(2, 2, 5, 7, 7),
TYPE=c("DEL", "DEL", "DUP", "TRA", "TRA"))
el$COLOR[el$TYPE=="DEL"] <- "red"
el$COLOR[el$TYPE=="DUP"] <- "green"
el$COLOR[el$TYPE=="INS"] <- "yellow"
el$COLOR[el$TYPE=="INV"] <- "brown"
el$COLOR[el$TYPE=="TRA"] <- "blue"
#> el
# Partner1 Partner2 TYPE COLOR
#1 1 2 DEL red
#2 3 2 DEL red
#3 4 5 DUP green
#4 5 7 TRA blue
#5 6 7 TRA blue
g <- graph_from_data_frame(d = el, directed = TRUE)
plot(g, edge.color=el$COLOR)
### here decomposing the graph into 2 SUBGRAPHS :
g_decompose <- decompose.graph(g)
plot(g_decompose[[1]], edge.color=el$COLOR) ## here the edges are red (that
is fine)
plot(g_decompose[[2]], edge.color=el$COLOR) ## here the edges shall be blue
and green, not red and green .
#####################################################
many thanks !
-- bogdan
[[alternative HTML version deleted]]
More information about the R-help
mailing list