Considering a graph of nodes from networkx how can I apply a kmean cluster of all the nodes where specific nodes are considered the centroids of the clusters. In other words, assume we have this graph:
import networkx as nx
s = [0,3,2,3,4,5,1]
t = [1,2,7,4,6,6,5]
dist = [3,2,5,1,5,4,2]
G = nx.Graph()
for i in range(len(s)):
G.add_edge(s[i],t[i],weight=dist[i])
I want to apply a kmean clustering on the network where for example I choose the centroids to be 3 and 6 and the graph will be clustered accordingly to produce two subgraphs (or as many centroids as I input)
I have been looking at the kmean clustering here https://www.learndatasci.com/tutorials/k-means-clustering-algorithms-python-intro/ and what that doesn't cover is the inputted centroids but rather it only considers number of clusters without a centroid node.