gpt4 book ai didi

javascript - Cytoscape 中的多个根节点

转载 作者:行者123 更新时间:2023-11-29 23:54:26 24 4
gpt4 key购买 nike

我正在 Cytoscape 中创建一个具有广度优先布局的树。

在布局选项中,我将一个节点设置为根节点。但是有没有办法让我有 2 个节点作为根节点?我在 cytoscape 引用中看到有以下布局选项:

var options = {
name: 'breadthfirst',
roots: undefined, // the roots of the trees
};

现在,可以使用其 ID 将单个节点设置为根节点。为了示例:

roots: "#a"

我该怎么做才能让一棵树有多个根,如图所示?

Multiple Root Tree representation

最佳答案

我解决了在该节点中放置一个名为“level3”的额外类的问题,然后我写了下一行:

cy.layout({name: 'breadthfirst', directed:false, roots:'node[classes @*="level3"]',padding: 5});

请记住,您可以向节点添加一些不同的类,只需使用它们之间的空格即可

关于javascript - Cytoscape 中的多个根节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42082975/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com