[R] Identifying tidygraph subgraphs

Wolfgang Grond grond @end|ng |rom number|@nd@de
Mon Apr 5 09:54:07 CEST 2021

Dear all,

imagine the following situation:

I want to create a tidygraph consisting of several subgraphs like in 
this example:

gr1  <-  create_notable 
<https://rdrr.io/cran/tidygraph/man/create_graphs.html>('bull')  %>%
   activate <https://rdrr.io/cran/tidygraph/man/activate.html>(nodes)  %>%
   mutate <https://rdrr.io/cran/tidygraph/man/reexports.html>(name 
<https://rdrr.io/r/base/name.html>  =  letters <https://rdrr.io/r/base/Constants.html>[1:5])
gr2  <-  create_ring <https://rdrr.io/cran/tidygraph/man/create_graphs.html>(10)  %>%
   activate <https://rdrr.io/cran/tidygraph/man/activate.html>(nodes)  %>%
   mutate <https://rdrr.io/cran/tidygraph/man/reexports.html>(name 
<https://rdrr.io/r/base/name.html>  =  letters <https://rdrr.io/r/base/Constants.html>[4:13])

gr1  %>%  graph_join <https://rdrr.io/cran/tidygraph/man/graph_join.html>(gr2) 
when the merged graph is plotted with ggraph afterwards, I would like to 
identify the former graphs gr1 and gr2 by their node color, so that it 
is possible to see which node originates from which source. The result 
will be as follows: nodes a, b, c have i. e. color blue as they 
originate from gr1, nodes f, g, h, i, j, k, l, m have i. e. color red as 
they originate from gr2, nodes d, e either have color blue or color red 
(depending in which sequence the graphs are joined), or nodes d. e have 
a third color, i. e. green as the belong to both graphs How can this be 
done? Thanks in advance. Wolfgang Grond

	[[alternative HTML version deleted]]

More information about the R-help mailing list