Skip to content

Commit

Permalink
Adjust metrics.scale.freeness to igraph changes
Browse files Browse the repository at this point in the history
Since version 2.0.0 of package `igraph`, the function `igraph::power_law_fit`
(and its deprecated alias `igraph::fit.power.law`) does not automatically
compute the p-value any more, which is needed by `metrics.scale.freeness`.
In version 2.1.1 of package `igraph`, they have added a new parameter
`p.value` to provide the possibility to enable p-value computation
again. In addition, they have added a parameter `p.precision` which
defaults to a precision of 0.01.

To make `metrics.scale.freeness` work again with the most recent version
of package `igraph`, the deprecated function calls to
`igraph::fit.power.law` are replaced by `igraph::power_law_fit` and are
adjusted to use the new parameter `p.value` to automatically compute the
p-value again. However, we do not make use of `p.precision` and rely on
the default precision instead.

Signed-off-by: Thomas Bock <[email protected]>
  • Loading branch information
bockthom authored and maxloeffler committed Dec 7, 2024
1 parent f591528 commit 4b0d522
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions util-networks-metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ metrics.scale.freeness = function(network, minimum.number.vertices = 30) {

## Power-law fiting
## (by Mitchell Joblin <[email protected]>, Siemens AG, 2012, 2013)
p.fit = igraph::power.law.fit(v.degree, implementation = "plfit")
p.fit = igraph::fit_power_law(v.degree, implementation = "plfit", p.value = TRUE)
param.names = c("alpha", "xmin", "KS.p")
res = list()
res[param.names] = p.fit[param.names]
Expand All @@ -250,7 +250,7 @@ metrics.scale.freeness = function(network, minimum.number.vertices = 30) {
& non.zero.degree.v.count >= minimum.number.vertices) {
## vertex degree is sorted above
x.min = v.degree[[minimum.number.vertices]]
p.fit = power.law.fit(v.degree, implementation = "plfit", xmin = x.min)
p.fit = igraph::fit_power_law(v.degree, implementation = "plfit", xmin = x.min, p.value = TRUE)
res[param.names] = p.fit[param.names]

## Check percent of vertices under power-law
Expand Down

0 comments on commit 4b0d522

Please sign in to comment.