【问题标题】:Can I add "cosmetic" edges to a cytoscape dagre layout?我可以在 cytoscape dagre 布局中添加“装饰”边缘吗?
【发布时间】:2019-02-27 06:24:48
【问题描述】:

我正在使用带有 dagre 布局的 cytoscape 来生成我的图形,并且我想包含额外的边(如下图红色所示)以有效地“注释”图形。但是,这并不像我希望的那样工作,因为 dagre 布局在生成图形时会考虑所有边。

我知道我可以使用“预设”布局来实现此行为,但是使用 dagre 布局有明显的好处,包括通过 expand-collapse 扩展来实现适当的展开-折叠功能。

我还尝试在 dagre 布局中使用“edgeWeight”选项,但没有效果。有人有什么建议吗?谢谢!

【问题讨论】:

  • 这是用于 cytoscape.js,而不是 cytoscape,所以我建议您更改标签...

标签: cytoscape.js


【解决方案1】:

我通过在渲染布局之前过滤掉边缘解决了这个问题:

var processedElements = this.cy
  .elements()
  // Filter out edges we don't want contributing to the layout of
  // of the graph
  .filter(el => !el.hasClass("unbundled-bezier-1"))

var layout = processedElements.layout({
  name: "dagre",
  rankDir: "LR"
})

layout.run();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 2022-06-27
    • 1970-01-01
    相关资源
    最近更新 更多