igraph / rigraph

igraph R package
https://r.igraph.org
532 stars 200 forks source link

no warning in strength() example #1293

Closed maelle closed 4 months ago

maelle commented 4 months ago

The comment below is from the example text.

maelle commented 4 months ago
library("igraph")
#> 
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#> 
#>     decompose, spectrum
#> The following object is masked from 'package:base':
#> 
#>     union
# No weights, a warning is given
g <- make_ring(10)
strength(g)
#>  [1] 2 2 2 2 2 2 2 2 2 2

Created on 2024-03-11 with reprex v2.1.0

szhorvat commented 4 months ago

Would you have time to help with this and test if 1.6.0 (based on 0.9) and 1.2.6 (based on 0.8) give a warning? My hypothesis is that there was a warning in the past but it was removed in the C core, but I didn't find when this might have happened.

Alternatively, just remove the comment and close this. It's not worth the time and I wouldn't support strength() giving a warning when there are no weights (even if this naively makes sense)

maelle commented 4 months ago

ok, let me do this!

szhorvat commented 4 months ago

Just remove the comment, don't spend time.

Strength only differs from degree when there are weights, which supports giving a warning, so someone may have done this. But it is much more useful not to issue warnings, just take all weights to be 1.

maelle commented 4 months ago

Ok!