wiheto / teneto

Temporal Network Tools
GNU General Public License v3.0
85 stars 26 forks source link

wrong number of nodes from TN.N and in netshape #78

Closed maximelucas closed 3 years ago

maximelucas commented 3 years ago

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 3 years ago

Nice catch.

Seems like a good suggestion, feel free to submit a PR! Or I'll add it when I do some small edits.

wiheto commented 3 years ago

Closed in #79