My network can be seen as a multi-edge directional graph. When I cluster nodes, I want each edge connecting a node-inside the cluster with a node-outside the cluster to be shown. However, the clustering function returns only a single edge for each node-inside/node-outside the network (typically the first one).
See an example here https://jsfiddle.net/o9c62pmk/ and the corresponding code below:
var container = document.getElementById("mynetwork");
var data = {
"nodes": [
{
"id": "pod2",
"label": "pod2",
"deployment": "Deployment-1",
"group": "Deployment-1"
},
{
"id": "pod4",
"label": "pod4"
},
{
"id": "pod3",
"label": "pod3",
"deployment": "Deployment-1",
"group": "Deployment-1"
},
{
"id": "pod1",
"label": "pod1"
}
],
"edges": [
{
"id": 0,
"from": "pod2",
"to": "pod4",
"label": "443"
},
{
"id": 1,
"from": "pod2",
"to": "pod4",
"label": "8080"
},
{
"id": 2,
"from": "pod3",
"to": "pod4",
"label": "80"
},
{
"id": 3,
"from": "pod2",
"to": "pod3",
"label": "80"
},
{
"id": 4,
"from": "pod1",
"to": "pod4",
"label": "8080"
}
]
};
var options = { layout: { randomSeed: 8 } };
var network = new vis.Network(container, data, options);
network.on("selectNode", function (params) {
if (params.nodes.length == 1) {
if (network.isCluster(params.nodes[0]) == true) {
network.openCluster(params.nodes[0]);
}
}
});
function clusterByDeployment() {
network.setData(data);
var clusterOptionsByData = {
joinCondition: function (childOptions) {
return childOptions.group === "Deployment-1";
},
clusterNodeProperties: {
id: "cidCluster",
borderWidth: 3,
shape: "database",
},
};
network.cluster(clusterOptionsByData);
}
In the example the clustering shows only 1 edge with label “443” whereas there should be 3 edges “443,80,8080”.
I would like to either see the 3 edges or even a single one with an updated label.
What am I doing wrong?
Thanks in advance.