2
$\begingroup$

What would be a good way of measuring propensity of contagion between two sets of nodes in a network? I tried creating an index that includes path distance and number of shortest paths, but network size impacts too much the result.

data <- read.table(text="
                         A   B   C   D   E   F   G
                     A   0   1   0   1   0   1   1
                     B   1   0   1   1   0   1   0
                     C   0   0   0   0   0   0   1
                     D   1   1   0   0   1   0   0
                     E   0   0   0   1   0   1   1
                     F   0   1   0   0   1   0   1
                     G   1   0   1   0   1   1   0", header=TRUE)

mat <- as.matrix(data)
gs <- graph.adjacency(mat, mode="undirected", add.rownames = T)

I select two sets of nodes:

set_A <- c(A,B,C)
set_B <- c(E,F,G)

My failed attempt: First I measure the distance between the two sets and then I count the number of shortest paths between the two sets:

Distances_AB <- distances(gs,set_A,set_B)
Shortest_AB <- all_shortest_paths(gs,set_A,set_B)
length(Shortest_AB$res)

The problem with this solution is that the number of shortest paths increases exponentially as path distance increases, and I'm not sure how to control for this. Any ideas on a good way to measure contagion propensity?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.