Dash Cytoscapes Layout:grid/concentric position function callback

Hey, I’m currently building a Dash app with a cytoscape and having a question:
Im changing the layout of my cytoscape via radiobuttons.

  1. I wanted to avoid overlapping on my preset layout. It almost looks like a grid so I thought I also can take grid and somehow avoid the overlapping with it.
    However I also have to take the positions into account, setting position of each node individually.
    I found the
position: function( node ){}, // returns { row, col } for element

-property of the layout on the cytoscape website however I cannot pass a function because its not Json serializable.
I think here it wouldn’t be much of an issue if theres no way to do it, I could also try to avoid overlapping in preset with some math.

2: On my concentric layout I also need to give some nodes a higher degree/(higher circle level) than others. Is there a way to do it except over functions I cannot pass:

concentric: function( node ){ // returns numeric value for each node, placing higher nodes in levels towards the centre
  return node.degree();
  },
  levelWidth: function( nodes ){ // the variation of concentric values in each level
  return nodes.maxDegree() / 4;
  },

Thank you for your time

Hey @Louis welcome to the forums.

Cytoscape is not used very often considering the amount of questions we get on the forums. So I would suggest adding more information/images/explanation to your question.

You are using, Dash right? Concerning the serialization: you could use a dcc.Store() with a ServerSideOutput from dash-extensions if you can use pickle on your object.

Thank you, Im trying this serialization in the next weeks and replying again.

1 Like