network icon indicating copy to clipboard operation
network copied to clipboard

convention for `class` of network size attribute: `integer` or `numeric`?

Open chad-klumb opened this issue 2 years ago • 1 comments

It seems this is initialized to numeric by network.initialize, e.g.

require(network)
nw <- network.initialize(100000L, bip = 60000L, directed = FALSE)
class(network.size(nw))
# [1] "numeric"
network.dyadcount(nw)
# [1] 2.4e+09

However, add.vertices and delete.vertices appear to change it to integer, which can e.g. lead to network.dyadcount overflowing:

require(network)
nw <- network.initialize(100000L, bip = 60000L, directed = FALSE)
delete.vertices(nw, 1)
class(network.size(nw))
# [1] "integer"
network.dyadcount(nw)
# [1] NA
# Warning message:
# In nactor * nevent : NAs produced by integer overflow
require(network)
nw <- network.initialize(100000L, bip = 60000L, directed = FALSE)
add.vertices(nw, 1)
class(network.size(nw))
# [1] "integer"
network.dyadcount(nw)
# [1] NA
# Warning message:
# In nactor * nevent : NAs produced by integer overflow

chad-klumb avatar Apr 21 '22 11:04 chad-klumb

Assuming our networks won't exceed 2 billion nodes, we should be fine to standardise on integer; but in dyad count calculation we should, indeed, upcast to numeric.

krivit avatar Apr 25 '22 12:04 krivit