Description
Since jLouvain is not using an immutable datastructure it is possible that the data provided during initialization (nodes and edges) will be different when calculating the community.
How to reproduce
This behavior can be seen in the provided example/example.html
The prepared community on line 298 var community = jLouvain().nodes(node_data).edges(edge_data); will be calculated in the on-click handler defined in line 367. This will happen AFTER d3 used the data to display the graph and AFTER d3 modified edge_data
Moving line 364 var community_assignment_result = community(); up to line 299 will result in different communities:


Reason
The library d3 is changing the value inside edge_data from {source : 1 ..} to {source: {key: "1", value: 1, index: 1 ...}}. Therefore using edge.source will result in unexpected behavior. Especially using partition[edge.source] will return undefined.
Description
Since jLouvain is not using an immutable datastructure it is possible that the data provided during initialization (nodes and edges) will be different when calculating the community.
How to reproduce
This behavior can be seen in the provided example/example.html
The prepared
communityon line 298var community = jLouvain().nodes(node_data).edges(edge_data);will be calculated in the on-click handler defined in line 367. This will happen AFTER d3 used the data to display the graph and AFTER d3 modifiededge_dataMoving line 364


var community_assignment_result = community();up to line 299 will result in different communities:Reason
The library d3 is changing the value inside
edge_datafrom{source : 1 ..}to{source: {key: "1", value: 1, index: 1 ...}}. Therefore usingedge.sourcewill result in unexpected behavior. Especially usingpartition[edge.source]will returnundefined.