Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior because of mutable data #14

Open
jbierboms opened this issue Apr 27, 2021 · 0 comments
Open

Unexpected behavior because of mutable data #14

jbierboms opened this issue Apr 27, 2021 · 0 comments

Comments

@jbierboms
Copy link

jbierboms commented Apr 27, 2021

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:
g1
g2

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant