I am trying to do the Force-Directed Graph from this example but my data is really big (5000 nodes) so I want to remove some nodes that do not link to any other nodes.
However, in my JSON, every node has at least 1 link (that link to itself). This is an example of my data:
{"directed": false, "graph": {},
"nodes": [{"id": 0}, {"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5},
{"id": 6}, {"id": 7}, {"id": 8}, {"id": 9}, {"id": 10}, {"id": 11}, {"id": 12}],
"links": [{"source": 0, "target": 0}, {"source": 1, "target": 1},
{"source": 2, "target": 2}, {"source": 3, "target": 3},
{"source": 4, "target": 4}, {"source": 5, "target": 5},
{"source": 6, "target": 6}, {"source": 7, "target": 8},
{"source": 7, "target": 9}, {"source": 7, "target": 10},
{"source": 7, "target": 11}, {"source": 7, "target": 7},
{"source": 8, "target": 8}, {"source": 9, "target": 9},
{"source": 10, "target": 10}, {"source": 11, "target": 11},
{"source": 12, "target": 12}], "multigraph": false}
I.e., node id:0 only has link {"source": 0, "target": 0} so it should get removed but node id:7 has links {"source": 7, "target": 8}, {"source": 7, "target": 7}. It is linked to another node so it should not get removed.
My question is how do I delete nodes that only link to itself?