wrong number of nodes from TN.N and in netshape
Closed this issue · 2 comments
maximelucas commented
Running
import teneto as tnt
TN = tnt.TemporalNetwork()
tedges = [[1, 2, 100],
[1, 2, 101],
[1, 2, 102],
[1, 2, 103]]
TN.add_edge(tedges)
yields a TN.netshape
of (3,4) and TN.N
of 3 where in both cases the number of nodes should be 2 and not 3.
This is because the current line (322) in _calc_netshape
in the TemporalNetwork
class assumes integer node names and counts from 0:
n_nodes = self.network[['i', 'j']].max(axis=1).max()+1
which we could replace it with this for example
n_nodes = len(np.unique(TN.network[['i', 'j']].values))
wiheto commented
Nice catch.
Seems like a good suggestion, feel free to submit a PR! Or I'll add it when I do some small edits.