How to have one node in two or three cluster using visjs

917 Views Asked by At

How can I cluster a node in two different clusters?

for example:

var nodes = [
    {id: 4, label: 'Node 4', cid:[1]},
    {id: 5, label: 'Node 5', cid: [2]},
    {id: 6, label: 'Node 6', cid:[1,2]},
    {id: 7, label: 'Node 7', cid:[1]}
]

Node 6 should be present in both cluster 1 and 2. How can I achieve this?

I tried adding joinCondition like below:

var clusterIds = [1,2];

for(var i = 0; i < clusterId.length; i++){
    options[i] = {
        joinCondition:function(nodeOptions) {
            return (nodeOptions.cid.indexOf(clusterId[i]) > - 1);
        }
    }
    network.cluster(options[i]);
}

but I am getting the node only in one cluster.

0

There are 0 best solutions below