rnodesigraphvertices

Compare nodes in 2 graphs igraph R


I'm using igraph in RSudio & have 2 directed weighted graphs (A & B) & all I want is to find, if it exists, is the list of shared nodes.

i.e. V(A) conjunct V(B)

A: 117->55  119->55  119->119 119->127 55 ->117 55 ->119 59 ->119 123->23  23 ->119 127->123 127->119 127->127 127->89 

B: 21 ->55  51 ->119 117->53  117->119 119->53  119->127 119->119 119->80  55 ->119 123->21  127->123 127->119 53 ->117

I found this answer in Python but the docs for isomorphic.vf2 are too opaque for me, so I haven't found an equivalent procedure in R

I tried,

intersect(V(A), V(B))

But just get,

[1] 1 2 3 4 5 6 7 8

I was expecting the set of shared node labels.


Solution

  • I guess you can try names, e.g.,

    intersect(names(V(A)),names(V(B)))
    

    or

    V(graph.intersection(A, B, keep.all.vertices = FALSE))