CWTSLeiden / networkanalysis

Java package that provides data structures and algorithms for network analysis.
MIT License
144 stars 33 forks source link

error message : duplicate values while creating network #4

Closed almugabo closed 3 years ago

almugabo commented 5 years ago

Great tool !!!

I get the following error when I try to run the RunNetworkClustering.jar a large network .

Error while creating network: For each node, corresponding elements of neighbors array must not include duplicate values.

May I propose to make the error message more explicit ? Does it means that the program found at least one node (source) with same target multiple times or something else ?

Just for clarification : I double checked my input file. It does not have any duplicates (distinct) nor self-loops (source_node<> source_target).

vtraag commented 5 years ago

Thanks!

Yes, perhaps we can explicitly mention the duplicate element that we encountered, we will look into it.

Note that the network is assumed to be undirected. In other words, if you have the edges listed as source node -> target node, then make sure that the reverse edge is not also present. For example, if the edge 3, 4 is included, the edge 4, 3 should not be included. Could you check whether removing such duplicates resolves the issue?

almugabo commented 5 years ago

Thanks for the prompt reply. Yes the "reciprocal" edges were the problems. When removed everything works fine. Explicitly mentioning the "offending" can help, especially if the input network is large, find them can be time consuming.

vtraag commented 5 years ago

Good to hear it is solved!

Yes, I can understand, we'll look into improving the error message. I'll leave the issue open for now.

Marmeladenbrot commented 5 years ago

Are directed networks (and therefore multiple edges for the same nodes) possible in the algorithm? Or will it stay undirected network only?

vtraag commented 5 years ago

Multiple edges are not possible in this implementation. However, multiple edges can simply be represented as a single weighted edge, with the weight the multiplicity of the edges (or the sum of the weights).

This implementation accepts only undirected networks. Note that for CPM the direction is not important, while for modularity directionality may play a role. The Python implementation does allow for directed networks with multiple edges though.

FlashZdy commented 3 years ago

Does nodes must be continual and start from 0 ?

vtraag commented 3 years ago

Yes

vtraag commented 3 years ago

This is now fixed in the master branch. We now provide an explicit line numbers on errors, see commit 44829f1e29114a6ec70b66613faf402d60414240