0

I'm building a graph which allows edges to be toggled on/off. I need to be able to add and remove them repeatedly. I have noticed this error with node degrees with nodes attached to toggled edges. I've included an example.

My code:

allElements = cy.elements();
....
var allEdges  = allElements.filter('edge');                
var allNodes = allElements.filter('node');
for(var i=0; i<5; i++){
    // DELETE
    var printThis = []; 
    allNodes.filter(function(i,ele){
        printThis.push(ele.degree());
    });
    console.log(printThis);
    cy.remove(allEdges);
    cy.add(allEdges);
}

Returns:

[1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 6, 1, 2, 1, 1, 1, 36, 8, 3, 4, 4, 2, 1, 1, 1, 1, 1, 1, 2]
[1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 6, 1, 2, 1, 1, 1, 36, 8, 3, 4, 4, 2, 1, 1, 1, 1, 1, 1, 2] 
[2, 2, 2, 2, 2, 6, 2, 2, 2, 2, 2, 12, 2, 4, 2, 2, 2, 72, 16, 6, 8, 8, 4, 2, 2, 2, 2, 2, 2, 4] 
[3, 3, 3, 3, 3, 9, 3, 3, 3, 3, 3, 18, 3, 6, 3, 3, 3, 108, 24, 9, 12, 12, 6, 3, 3, 3, 3, 3, 3, 6] 
[4, 4, 4, 4, 4, 12, 4, 4, 4, 4, 4, 24, 4, 8, 4, 4, 4, 144, 32, 12, 16, 16, 8, 4, 4, 4, 4, 4, 4, 8] 

Which shows that removing edges after the first time dont decrease the degree of the nodes they're attached to.

How can I have cytoscape return the correct degree?

JD.
  • 2,361
  • 6
  • 25
  • 38

1 Answers1

0

Thank you for notifying us of the issue. We will get a fix in for 2.0.3 -M https://github.com/cytoscape/cytoscape.js/issues/360

maxkfranz
  • 11,896
  • 1
  • 27
  • 36