I have read the can-an-igraph-object-have-directed-and-undirected-edges.
I have two graphs gUed
and gDed
.
The gUed
is the undirected graph and the gDed
is the directed one.
I need to union these graph into one.
I made this union with the edge list.
library(igraph)
gDed <- graph.formula(1-+2, 2-+3, 3-+4, 4-+5)
gUed <- graph.formula(6--1, 7--2, 8--4, 9--5)
EL = as_edgelist(gDed, names = TRUE)
EL1 = as_edgelist(gUed, names = TRUE)
ELU = rbind(EL, EL1)
ELU = ELU[!duplicated(ELU),]
GU = graph_from_edgelist(ELU)
## To check the result
par(mfrow=c(1,3))
plot(gDed)
plot(gUed)
plot(GU)
But I have a problem: in new graph GU
all edges are directed.
Question. How to union two graphs and save directed and undirected components in new graph?