我正在 Cytoscape 中创建一个具有广度优先布局的树。
在布局选项中,我将一个节点设置为根节点。但是有没有办法让我有 2 个节点作为根节点? 我在 cytoscape 引用中看到有以下布局选项:
var options = {
name: 'breadthfirst',
roots: undefined, // the roots of the trees
};
现在,可以使用其 ID 将单个节点设置为根节点。为了 示例:
roots: "#a"
我该怎么做才能让一棵树有多个根,如图所示?
最佳答案
我解决了在该节点中放置一个名为“level3”的额外类的问题,然后我写了下一行:
cy.layout({name: 'breadthfirst', directed:false, roots:'node[classes @*="level3"]',padding: 5});
请记住,您可以向节点添加一些不同的类,只需使用它们之间的空格即可
关于javascript - Cytoscape 中的多个根节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42082975/