Open jordansaethre opened 4 years ago
The underlying library for the html vis is d3 force graph, and no, you can't specify edge length.
On Mon, Sep 14, 2020, 8:04 AM jordansaethre notifications@github.com wrote:
Is there a way to dictate how long the edges are based on the nodes that are being connected? I have been using this tool to visualize a simplicial complex that is the result of my own algorithm (not the mapper algorithm) and I want edge length to have meaning. If this is not already a feature would anyone be able to point me to the section of code that I would need to modify to make this happen? I have messed around with quite a few things, but haven't had any luck.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/scikit-tda/kepler-mapper/issues/197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI6Y7O4LNYNR7XY5OFRJR3SFYPINANCNFSM4RLUSCSQ .
If you're okay with static graphs, the plotly visualization functionality should let you specify edge lengths. The entry point is here: https://github.com/scikit-tda/kepler-mapper/blob/956b8c90b93734851e4aa0da5d166c0a65e944b7/kmapper/plotlyviz.py#L61-L86
Right now, it does not support supplying some sort of distance matrix, but I believe you should be able to thread a parameter all the way down to the point the graph_layout
argument is used.
You might also try the networkx
visualizations. They could be easier to work with.
In addition to @sauln 's, suggestions, I also misspoke -- d3 force graphs do let you specify link distance, see https://github.com/d3/d3-force#link_distance . I have a PR in the works that upgrades d3 to the latest version which use the linked docs
It might be possible to overwrite the d3 force layout also..
You can supply a function to the linkDistance
method that will instantiate the distance for each link. For an example, you can see http://bl.ocks.org/sathomas/83515b77c2764837aac2
force.linkDistance(function(link) {
return link.graph === 0 ? height/2 : height/4;
});
Maybe instead you could do something like
force.linkDistance(function(link) {
return link.length;
});
and then turn gravity (and probably other parameters) to 0 so the link length doesn't change?
@jordansaethre If you can get it to work, it'd be awesome to have this as a contribution to the library!
@sauln I think the more recent versions of d3-force respect the link distance more than the current version does, so gravity wouldn't have to be messed with. Also, I think the concept of gravity has been replaced by charge
in the latest versions. You can see some of the changes I had to make to the force layout in the most recent wip pr.
To emphasize, if any work is going to be done on this, the changes between the d3-force version used in my WIP and the version on master are so drastic, that any changes to the d3 code should hold off a bit.
@sauln @deargle I will definitely give it a shot. Thanks for the tips guys!
Is there a way to dictate how long the edges are based on the nodes that are being connected? I have been using this tool to visualize a simplicial complex that is the result of my own algorithm (not the mapper algorithm) and I want edge length to have meaning. If this is not already a feature would anyone be able to point me to the section of code that I would need to modify to make this happen? I have messed around with quite a few things, but haven't had any luck.