-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Improvements to forceatlas2 algorithm #488
Conversation
datashader/layout.py
Outdated
nlen = len(nodes) | ||
if 'id' in nodes: | ||
index = dict(zip(nodes['id'].values, range(nlen))) | ||
else: | ||
index = dict(zip(nodes.index.values, range(nlen))) | ||
|
||
if 'weight' not in edges: | ||
if params.ignore_weights or 'weight' not in edges: | ||
edges = edges.copy() | ||
edges['weight'] = np.ones(len(edges)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a very expensive step, and doesn't seem feasible as an approach in general, but I guess we can merge and come back to that later.
Instead of copying the dataframe and creating another single-value column if the weights are ignored, we use an if-statement to specify the default weight.
Creating a temporary list of tuples that are immediately thrown away is redundant and wasteful.
After profiling the memory usage for sparse matrix creation, it surprisingly turned out that removing the temporary tuple list had a far larger impact than the updated steps taken when ignoring weights. The overall time didn't change noticeably in either case. |
Ok, sounds great! I'll merge when tests pass. |
* Replace constants with parameters * Check for loops * Optionally ignore weights during layout
The datatype of the coordinates is now consistent. We also check for edges pointing to themselves.
Related to #485