javascriptbinary-search-treecytoscape.jsdagre

Drawing binary search tree with Cytoscape.js


I am trying to draw a binary search tree using Cytoscape.js. I am using Dagre layout. In my tree, each node has exactly two children - I am creating nodes with 'null' labels for empty subtrees. My problem is that sometimes the left child is on the right side and vice versa.

How can I set which node should be the left child and which should be the right?


Solution

  • From the dagre documentation, the only parameters that look as though they could affect order include:

    If neither one allows specifying order in the resultant dagre layout, then you'll have to file a feature request with dagre. The cytoscape-dagre package is just a wrapper.