Asad Ali Khan
Asad Ali Khan

Reputation: 307

Get parallel edges and give them color

I want to get list of all parallel edges within a collection and give them seperate color

My code is

cy.elements().parallelEdges().animate({ 'style':{'line-color':'coral', 'width': '10px'} }, {duration: 1000 })

But it end up in coloring all edges....

enter image description here

Upvotes: 0

Views: 345

Answers (1)

Stephan T.
Stephan T.

Reputation: 6074

You call the function on all elements in cytoscape, the documentation implys, that you have to callthe function on edges.

cy.edges().parallelEdges().animate();

Edit: cy.edges() wont work, the funciton is designed to give you the parallel edges to a set collection of edges, so if you want to achieve this, I think you have to:

  • Iterate through all nodes via cy.nodes() and a for loop
  • Get the edges of the current node with cy.edges("[source = theRightId]")
  • Check for every edge (Just one edge for the following function!!) if it has a parallel edge via cy.$('#idOfEdge').parallelEdges()
  • Put those with a parallel edge in a cy.collection() [add elements in a collection with: yourCollection = yourCollection.add(theParallelEdges)]

Upvotes: 1

Related Questions