[R] coloring edges in IGRAPH

Bogdan Tanasa t@n@@@ @end|ng |rom gm@||@com
Wed Jul 25 04:34:46 CEST 2018


Thank you all. Think I did solve it by using the code below :

plot(g_decompose[[1]], edge.color=edge_attr(g_decompose[[1]])$COLOR)

plot(g_decompose[[2]], edge.color=edge_attr(g_decompose[[2]])$COLOR)

On Tue, Jul 24, 2018 at 5:48 PM, Bogdan Tanasa <tanasa using gmail.com> wrote:

> 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