简体   繁体   中英

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?

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

  • The ordering of the nodes and edges in the graph itself.
  • The ranker option.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM