medialab / ipysigma

A Jupyter widget using sigma.js to render interactive networks.
https://medialab.github.io/ipysigma/demo.html
MIT License
206 stars 19 forks source link

Layout algorithm settings #214

Open simull opened 1 year ago

simull commented 1 year ago

Hi,

thanks for this great project! I am plotting a network and try to specify layout settings (see below). When I specify the settings in the Sigma() function, only some of the settings seem to have an effect. I could not find in the description which of the settings are implemented in Sigma and which ones are not. First, it would be great to have more information in the documentation of how to adapt the layout. Second, is there a possibility to implement the functionalities of Gephi settings for ForceAtlas2 layout algorithm?

I try to increase the scaling ration or prevent_overlapping, for instance, but it does not affect the visualization of the network.

# Prepare ForceAtlas2 layout settings
layout = {
          # Behavior alternatives
              'outboundAttractionDistribution':True, 
              'linLogMode': True,
              'adjustSizes': False,
              'edgeWeightInfluence':0.5, 
          # Performance
              'itterTolerance':1.0,
              'barnesHutOptimize':True, 
              'barnesHutTheta': 1.2,
              'multiThreaded':False, # Not implemented
          # Tuning
              'scalingRatio':100.0,
              'strongGravityMode':False,
              'gravity':1,
              'prevent_overlapping':True
         }
Sigma(G, node_size=G.degree, layout=layout)
Yomguithereal commented 1 year ago

Hello @simull,

the layout settings are documented here: https://graphology.github.io/standard-library/layout-forceatlas2#settings and should be given to the layout_settings kwarg, not layout which expects a mapping for nodes to their positions, if you have an extraneous layout of your graph to give (check out the API reference for more details.

Second, is there a possibility to implement the functionalities of Gephi settings for ForceAtlas2 layout algorithm?

The implementation of the ForceAtlas2 algorithm used by ipysigma is basically the same as Gephi and was written by the same author. The name of the settings differ somehow for historical reasons beyond my control, sorry :). This said, Gephi and ipysigma have different ways of handling positions on screen. To simplify, for UX reasons, ipysigma always rescale the graph on screen which means the anticollision of the FA2 algorithm in ipysigma cannot work very well. This said, why not using the anticollision algorithm provided by the widget after the FA2 algorithm ran?