Reading a graph from the web and running k-means clustering
Source code name: "graph_medusa_kmeans.py"
Programming language: Python
Topic: Data mining/Graphs
DMelt Version 1.8. Last modified: 01/29/2021. License: Pro
https://datamelt.org/code/cache/graph_medusa_kmeans_5023.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from jhplot import *

http="https://datamelt.org/examples/data/"
print Web.get(http+"sample1_medusa.dat")

c=HMedusa()
c.loadFile("sample1_medusa.dat")
gg=c.getGraph()
c.visible()    # show the graph 

from medusa.georgios.ClusteringAlgorithms import KMeans2
num_of_clusters=6  # run k-means with 6 clusters 
kmeans = KMeans2(num_of_clusters, gg)
kmeans.runKMeans();
nodes_clusters=kmeans.getClusterMap()
print kmeans.getReport()

from medusa.georgios.Layouts import Layouts
Layouts.Apply_Kmeans_Clustering(gg, c.getPanel(), num_of_clusters) # asks for 6 clusters 
c.update()




You see the box below because you did not login.