tgdwyer / WebCola

Javascript constraint-based graph layout
http://marvl.infotech.monash.edu/webcola/
MIT License
2.01k stars 257 forks source link

Support Arbitrary ID instead of Node Index #231

Open namwkim opened 7 years ago

namwkim commented 7 years ago

Here is a use case:

Let's say I have a large graph (G). I want to create multiple coordinated views with different sub-graphs (SG) of G.

For now, it seems that we have to change the source and target of each link in SG so that they refer to node indices, which makes it tricky to maintain the connections among the subgraphs. In other words, the same link in G can have different source & target in each SG.

Added I think I meant this https://github.com/d3/d3-force#link_id

colin-combe commented 7 years ago

hi - this possibly doesn't help because you have a solution already (with the link.id function), but it seems its possible not to use node indices and provide the javascript objects representing nodes directly as the source and target of the link. Seems to work, I had a similar problem and solved it by doing it this way,

best of luck, colin [edit: issue could be closed if you have a solution :) ]

andrewvc commented 7 years ago

@colin-combe I tried using the objects directly and that seems to not work consistently across features last I checked, so I too am storing the index of the object on the node and just using that.

lksnmnn commented 5 years ago

This really threw me off. I tried layouting my graph where the nodes have arbitrary id's (i.e. strings (uuid)) but it always crashed since the distance calculator expected target and source id's to be with [0, nodes.length-1]. I now have to map the graph to an internal model with different IDs and different values for source and target which will slow down my code for larger graphs.