2

I created a graph (igraph) from interview data. I would like to compare the sub-graphs of each interview to have a relative distance from each one. I found that I could use Hamming's distance. There are a lot of packages that offer functions to calculate distance. But I can't figure out how to calculate the distance between each sub-graph.

As an exemple :

library(igraph)
g1 <- graph_from_literal(1-2-3-4-1, 2-5-4, 1-5)
V(g1)$interview <- 1
g2 <- graph_from_literal(6-7-9,8-4-2-10,1-10-9)
V(g2)$interview <- 2
big.g <- g1 + g2
set.seed(1234)
plot(big.g)

I would like to know how far g1 (from interview 1) is to g2. A kind of similarity or dissimilarity index. The Hamming distances seems to be a way but I don't know how to deal with ...

delaye
  • 1,357
  • 27
  • 45
  • Can you give us a little mock-up to demonstrate your problem in a reproducible way? – Allan Cameron Oct 07 '20 at 08:52
  • @AllanCameron regarding the exemple, I tried to use `sna::hdist()` but I need to have the same dimension for `g1` and `g2` . this is rarely the case – delaye Oct 09 '20 at 06:55

1 Answers1

2

I have find a solution from here

int <- graph.intersection(g1,g2)
n.dist <- ecount(g1)+ecount(g2)-2*ecount(int)
n.dist

##14  <- result  
delaye
  • 1,357
  • 27
  • 45