Hello, I have a problem when I finish my code. Despite detecting communities, I can not "draw" a line between the elements that are part of the same community. I tried with Matplotlib and Networkx and I could not.
# classify
community = dict()
for index,i in enumerate(output):
temp = [np.linalg.norm(i-output[0,:]),
np.linalg.norm(i-output[16,:]),
np.linalg.norm(i-output[18,:]),
np.linalg.norm(i-output[24,:])]
belongs = temp.index(min(temp))
if belongs not in community.keys():
community[belongs]=[]
community[belongs].append(index)
else:
community[belongs].append(index)
print(community)
# draw
import matplotlib.pyplot as plt
import networkx as nx
G = nx.Graph()
for i,_ in enumerate(output[:,0]):
plt.annotate(i,(output[:,0][i],output[:,1][i]))
plt.scatter(output[:,0],output[:,1])
plt.show()
The idea would be that elements that belonged to the same community key would be interlinked.