Calculation of `constraint` sums along wrong axis
jsfalk opened this issue · comments
Joshua Falk commented
By summing over the columns rather than the rows here, I believe the code is currently computing C[i] = sum( [sum( p[i,j] + p[i,q] p[j,q], q in V[i], q != i,j )]^2, j in V[i], j != i). Note that the inner term should instead be p[i,q] p[q,j].
Below is a minimal working example showing that the results from influenceR
do not match those from igraph
(or networkX
). I've also verified the igraph
results by hand.
library(igraph)
library(influenceR)
graph_df <- data.frame(from=c(1, 1, 2, 2, 3), to=c(2, 4, 3, 4, 4))
g <- graph_from_data_frame(graph_df, directed=FALSE)
all.equal(influenceR::constraint(g), igraph::constraint(g))