我创造了两个带有以下边缘的无向igraph
graph1 => A--A
,A--B
和A--C
graph2 => B--A
,C--D
,D--E
和A--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)
我想找到graph2独有的边缘。因此,输出应该是:
# C--D D--E
答案 0 :(得分:1)
你可以尝试
get.edgelist(graph2-graph1)
# [,1] [,2]
# [1,] "C" "D"
# [2,] "D" "E"
或者,关于您的编辑:
E(graph2-graph1)
# + 2/2 edges (vertex names):
# [1] C--D D--E