Reputation: 176
I have created two undirected igraph with the following edges
graph1 => A--A
,A--B
andA--C
graph2 => B--A
,C--D
,D--E
andA--C
library(igraph)
my_data = data.frame(id1=c("A","A","A","B","C","A","D"),id2=c("A","B","C","A","D","C","E"))
graph1 = graph.data.frame(my_data[1:3,],directed=F)
graph2 = graph.data.frame(my_data[4:7,],directed=F)
I want to find edges unique to graph2. Therefore, the output should be like:
# C--D D--E
Upvotes: 0
Views: 328
Reputation: 54237
You could try
get.edgelist(graph2-graph1)
# [,1] [,2]
# [1,] "C" "D"
# [2,] "D" "E"
or, with regards to your edit:
E(graph2-graph1)
# + 2/2 edges (vertex names):
# [1] C--D D--E
Upvotes: 1