I have a force layout in D3.
I have many nodes with links joining them up. My problem is, I want to delete links if nodes meet a certain criteria.
Say I have nodes A,B,C.
Say this tilda character - '~' means connected.
If (A~B && A~C && B~C){
DELETE THE A~C link. //which would leave A~B~C
}
I've tried going through each link :
link.forEach(function{d){ ....
but I can't seem to get my head around how I would do the logic.
I would go through each node 3 times, check if A~B, A~C, B~C, but if i have 100 nodes that's going to be really slow.
Any help would be appreciated :)
Here is how my current edges/links array looks :
edges = [
{
"source": "A",
"target": "B",
"other information" : "randomstring",
"other information" : "randomstring"
},
{
"source": "B",
"target": "C",
"other information" : "randomstring",
"other information" : "randomstring"
} // and so on ....
]