vasturiano / force-graph

Force-directed graph rendered on HTML5 canvas
https://vasturiano.github.io/force-graph/example/directional-links-particles/
MIT License
1.49k stars 241 forks source link

How to display nodes together that are identical #352

Open MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM opened 2 months ago

MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM commented 2 months ago

Hello, I would like to group and display nodes based on the type of the link. For example, a link with type 1 will display nodes on the left, and a link with type 0 will display nodes on the right. May I know which attribute value should I use to set the node partition to display together? I hope to receive your answer 1716187218335

vasturiano commented 1 month ago

You could approach this in multiple ways, if you want to achieve such a layout. If your graph is completely acyclical you could take advantage of the built-in DAG layout mode, via .dagMode('lr'). Just make sure the direction of your links follow a left-to-right orientation in your graph data. Here's an example using the DAG mode: https://vasturiano.github.io/force-graph/example/tree/

Alternatively, you could use an additional clustering force, like d3-force-cluster, to group your nodes into meaningful spatial clusters.