This pull request is to update NOS.R to accomodate networks in which the degree of one or more nodes is 0.
Strona and Veench's equations for calculating the average number of node segregation/overlap contains the term min(d_i, d_j) in the denominator. However, if one of the nodes has degree 0, then min(d_i,d_j) will also be 0, and so the equation will have a division by 0 error.
For example:
> sample_graph <- rbind(c(0,1,0), c(0,3,4),c(0,0,2))
> sample_graph
[,1] 0 1 0
[2,] 0 3 4
[3,] 0 0 2
> NOS(sample_graph)
$Nbar
[1] NaN
$mod
[1] NA
$Nbar_higher
[1] NaN
$Nbar_lower
[1] 0.3333333
$mod_lower
[1] 1.154701
$mod_higher
[1] NA
Instead of computing both omega_ij and (S_ij - P_ij)/min(d_i,d_j) directly, we can cancel out the min(d_i, d_j) terms and avoid any divisions by 0.
This pull request is to update NOS.R to accomodate networks in which the degree of one or more nodes is 0.
Strona and Veench's equations for calculating the average number of node segregation/overlap contains the term min(d_i, d_j) in the denominator. However, if one of the nodes has degree 0, then min(d_i,d_j) will also be 0, and so the equation will have a division by 0 error.
For example:
Instead of computing both omega_ij and (S_ij - P_ij)/min(d_i,d_j) directly, we can cancel out the min(d_i, d_j) terms and avoid any divisions by 0.