SachaEpskamp / qgraph

Developmental version of qgraph
GNU General Public License v2.0
68 stars 21 forks source link

smallworldness() does not handle disconnected graphs #70

Open szhorvat opened 1 year ago

szhorvat commented 1 year ago

smallworldness() samples a large set of graphs with the same degree sequence as the input graph. Some of these will be disconnected, and average.path.length() will return infinity for them. The comment here is no longer valid starting with igraph 1.3:

https://github.com/SachaEpskamp/qgraph/blob/master/R/centralityFunctions.R#L344

  # compute the average shortest path length in random networks, the shortest path
  # length among unconnected nodes is computed as N, i.e., 1 plus the max possible path length
  lengthrnd<-sapply(rndA, average.path.length, directed=F, unconnected=F)

The distance between unconnected vertices is now taken to be infinity. See here for more details: https://r.igraph.org/reference/distances.html

Also note that the function name average.path.length() is deprecated in favour of mean_distance().

Ref: https://stackoverflow.com/q/75575906/695132

szhorvat commented 1 year ago

Actually, with reference to #69, you may be interested in the vl method of sample_degseq(), which samples connected graphs with a given degree sequence approximately uniformly. You'll find an overview of the issues around sampling connected graphs with given degrees in Section 2.1 of my paper here: http://dx.doi.org/10.1088/2632-072X/abced5