imohitmayank / jaal

Your interactive network visualizing dashboard
MIT License
321 stars 41 forks source link

Can't display a big graph #34

Open vherrera96 opened 3 years ago

vherrera96 commented 3 years ago

Hello! Thanks for this wonderful package! I've been playing with random graphs and it works great. However after trying to display a "big graph" (44 nodes and ~300 edges) something weird happens. It seems unable to stabilize the graph and it doesn't stop moving. Do you know how to fix this? Thank you! ezgif com-gif-maker (1)

imohitmayank commented 3 years ago

Hi @vherrera96, this behavior is observed when the physics stabilization engine is not able to converge (which is quite tough for skewed graphs with a high edge to node ratio). One way we can "force" convergence, is by reducing the steps taken for stabilization. Sample code (taken from readme example),

# init Jaal and run server
Jaal(edge_df, node_df).plot(vis_opts={'physics':{'stabilization':{'iterations': 100}}}) # define the convergence iteration of network

Here, you can try reducing the iterations value which will halt the stabilization effort. I should point out that while your graph will stop moving, it might be quite "messy" to see 😅

dumblob commented 3 years ago

Maybe allow some manual intervention by letting the user to choose node(s) and "fix them in place" (to slightly clean the "mess" you write about)?

Famondir commented 1 year ago

For me the stabilization key word did not help but to change the solver helped. I got best results with repulsion instead of the default BarnesHut:

Jaal(edge_df, node_df).plot(directed=True, vis_opts={'physics':{'solver' : 'repulsion'}})

Using ` the most important settings werecentralGravity(increased from 0.3 to 1.0 ) andspringConstant` (reduced from 0.04 to 0.01):

Jaal(edge_df, node_df).plot(directed=True, vis_opts={'physics': {'stabilization': False, 'barnesHut': {'centralGravity': 1, 'springConstant': 0.01}}})

You can turn stabilizationoff or keep it on (and adjust iterations to your liking).