I need to find n clusters such that the density of each cluster is above the threshold value of 50. I have 639 nodes, with average density assigned to the node attribute. Is there an algorithm to traverse through the nodes and merge nodes on attribute density so that I get n said clusters(should comprise connected nodes) with average density around and above the threshold value of 50. Each node can be connected to nodes with a connection to the said node.nx.connected_components(G) is 20. code snippet in python would be appreciated, as I'm a novice, with python and data science.
the image shows the nodes in blue and the connections in black