cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
10.09k stars 1.64k forks source link

Strict tree flow layout #803

Closed devradhika closed 9 years ago

devradhika commented 9 years ago

I have created graph as follows: hierarchi

Need structure like this: hierarchi1

So that I can add any number of nodes and link them to any hierarchy. Thanks!

devradhika commented 9 years ago

chart

also want to know about the padding between nodes, so that the charts will not overlap the other nodes

markov00 commented 9 years ago

@devradhika how do you have placed the charts over the graph? I'm really interested to see how it works, could you share that?

devradhika commented 9 years ago

These charts are only images, I have created it as an example. I have added nodes using the cy.add()

Referred: http://stackoverflow.com/questions/27799220/adding-extra-information-above-the-node-in-cytoscape-js

maxkfranz commented 9 years ago

I suspect this would require a heavily modified strategy in the breadthfirst layout. It tries to maximise space rather than tree flow.

It may be even better to have a separate layout solely for trees, though perhaps you may find Dagre sufficient for your purposes.

devradhika commented 9 years ago

In first figure above if I need to add new nodes to any branch of the tree I want it to be appear in straight line(i.e. vertically). is it possible?

maxkfranz commented 9 years ago

If you add nodes, you can position them manually wherever you like -- underneath a predecessor node if you like.

devradhika commented 9 years ago

http://jsfiddle.net/naL1byg8/ I have set the position values for first node however, not refecting anything in the output.

maxkfranz commented 9 years ago

You specified a layout. You can't have both, else the layout will override manual positions.

(1) Do manual positioning after layout at init, or

(2) use all manual positions.

devradhika commented 9 years ago

Thank you @maxkfranz There is another scenario i.e. tree can have any number of branches, for an example I used four branches. but if number of branches changes dynamically then setting the positions manually will not display the layout correctly.

maxkfranz commented 9 years ago

In (2), you don't use layout but rather position nodes manually according to your own specifications.

maxkfranz commented 9 years ago

Dagre might meet the requirements for this already.

maxkfranz commented 9 years ago

Closing for now, as Dagre should do this.