I have a ton of nodes in a graph, and with some filters I am able to remove some edges by some condition, using cy.remove(myCollection).
It happens sometimes that all edges to a node is removed and therefore its sitting alone without edges. Is there any way in Cytoscape to find these nodes without edges?
I was out in something like:
cy.nodes(/*:inside*/).filter(node => node.connectedEdges().size() === 0)
But this returns an empty collection?
I've had a similar problem: I had to remove nodes without edges from a graph. I solved it by using node.degree() with a function that cycles through nodes of my graph and finds those with degree=0 (both indegree and outdegree, which means that the nodes have neither sources nor targets).
`cy.nodes(function(element){
if( element.isNode() && element.degree()<1){
cy.remove(element)
}
})`
Hope it could be useful to fix your problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With