cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
10.09k stars 1.64k forks source link

Edge won't display if id is shared with a node #1354

Closed dominique-vassard closed 8 years ago

dominique-vassard commented 8 years ago

Hello, thanks for your great product!

I've encountered a bug recently: some edges won't display even if they were well defined in the initial JSON. In fact, it was because these particular edges has the same id as existing nodes. I use Neo4j as database and get data from it, and I there is shared ids between nodes and relationships but it isn't a problem there.

Is it a bad practice to have shared ids between nodes and edges (though i didn't think that could be a problem) or is it a bug in cytoscape?

If you tried to display a graph with the following nodes.edges, the edge between George and Kramer won't appear

nodes: [ { data: { id: 'j', name: 'Jerry' } }, { data: { id: 'e', name: 'Elaine' } }, { data: { id: 'k', name: 'Kramer' } }, { data: { id: 'g', name: 'George' } } ], edges: [ { data: { source: 'j', target: 'e' } }, { data: { source: 'j', target: 'k' } }, { data: { source: 'j', target: 'g' } }, { data: { source: 'e', target: 'j' } }, { data: { source: 'e', target: 'k' } }, { data: { source: 'k', target: 'j' } }, { data: { source: 'k', target: 'e' } }, { data: { id: 'j', source: 'k', target: 'g' } }, { data: { source: 'g', target: 'j' } } ]

Tkank you for the answer.

Ps: Sorry for the bad english

maxkfranz commented 8 years ago

Per graph, every element must have a unique ID. You are warned in the console if you don't follow this.

maxkfranz commented 8 years ago

Closing for now

Either use unique IDs for edges or use some method of transforming edge IDs so they are unique (e.g. prepend 'edge-').

dominique-vassard commented 8 years ago

Ok for me. In fact, I am using Neo4j as database and was using internal ids for graph display. As using Neo4j's internal ids is considered a bad practice (should use uuid for nodes and edges), it's fine to have this kind of behavior in Cytoscape.

Thank you