简体   繁体   English

使用Cytoscape.js绘制二进制搜索树

[英]Drawing binary search tree with Cytoscape.js

I am trying to draw a binary search tree using Cytoscape.js. 我正在尝试使用Cytoscape.js绘制二进制搜索树。 I am using Dagre layout. 我正在使用Dagre布局。 In my tree, each node has exactly two children - I am creating nodes with 'null' labels for empty subtrees. 在我的树中,每个节点正好有两个子节点-我正在为空的子树创建带有“ null”标签的节点。 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: dagre文档中 ,看起来可能会影响顺序的唯一参数包括:

  • The ordering of the nodes and edges in the graph itself. 图本身中节点和边的顺序。
  • The ranker option. ranker选项。

If neither one allows specifying order in the resultant dagre layout, then you'll have to file a feature request with dagre . 如果两个都不允许在生成的dagre布局中指定顺序,则必须向dagre提出功能请求。 The cytoscape-dagre package is just a wrapper. cytoscape-dagre包只是一个包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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