如何在cytoscape js中获取特定节点的边列表

How to get List of Edges for particular node in cytoscape js

我想跟踪所选节点的边缘,然后使用 cy.add() 完全在相同位置

将它们显示在图表上

我尝试使用 .connectedEdges() 检索边。但它给了我这个

u {length: 0, _private: {…}}

现在我不知道如何使用 cy.add()

跟踪边的 ID 以在图表上再次显示它们

是不是少了什么...

您可以通过 outgoers() 函数访问传出边,您还可以在其中获取要搜索的边的目标:

var outgoers = collection.outgoers();          // This contains all connected edges and their targets
var targets = collection.outgoers().targets(); // This contains all targets of your selected node
cy.ready(function () {
   for (node in outgoers) { 
      // Do what you like here
   }
});

最好用:

cy.nodes("[id = '" + id + "']").connectedEdges();