How to apply K-Medoids in many CFG?

I am having around 1000 DAG(Directed Acyclic Graph) of different files showing java.io.BufferedReader usage. Following is representation of one of the graphs

digraph G {
  9 [ label="9 : ROOT:setup()#0" ];
  10 [ label="10 : START IF" ];
  12 [ label="12 : java.net.URL.openConnection()#1" ];
  11 [ label="11 : END IF" ];
  13 [ label="13 : java.net.URL.openConnection()#0" ];
  14 [ label="14 : START IF" ];
  16 [ label="16 : java.net.HttpURLConnection.setRequestProperty()#2" ];
  15 [ label="15 : END IF" ];
  17 [ label="17 : START IF" ];
  19 [ label="19 : java.net.HttpURLConnection.addRequestProperty()#2" ];
  18 [ label="18 : END IF" ];
  21 [ label="21 : java.net.HttpURLConnection.setReadTimeout()#1" ];
  22 [ label="22 : java.net.HttpURLConnection.setConnectTimeout()#1" ];
  23 [ label="23 : java.net.HttpURLConnection.setUseCaches()#1" ];
  24 [ label="24 : staticjava.net.HttpURLConnection.setFollowRedirects()#1" ];
  25 [ label="25 : START IF" ];
  27 [ label="27 : java.net.HttpURLConnection.setRequestMethod()#1" ];
  28 [ label="28 : java.net.HttpURLConnection.setDoOutput()#1" ];
  29 [ label="29 : java.net.HttpURLConnection.setDoInput()#1" ];
  30 [ label="30 : java.net.HttpURLConnection.getOutputStream()#0" ];
  31 [ label="31 : java.io.DataOutputStream.init()#1" ];
  32 [ label="32 : java.io.DataOutputStream.writeBytes()#1" ];
  33 [ label="33 : java.io.DataOutputStream.flush()#0" ];
  26 [ label="26 : END IF" ];
  34 [ label="34 : java.net.HttpURLConnection.getInputStream()#0" ];
  35 [ label="35 : java.io.InputStreamReader.init()#1" ];
  36 [ label="36 : java.io.BufferedReader.init()#1" ];
  9 - 10;
  10 - 12;
  12 - 11;
  10 - 13;
  12 - 13;
  13 - 11;
  11 - 14;
  14 - 16;
  12 - 16;
  13 - 16;
  16 - 15;
  15 - 17;
  17 - 19;
  12 - 19;
  13 - 19;
  16 - 19;
  19 - 18;
  18 - 20;
  16 - 20;
  19 - 20;
  20 - 21;
  12 - 21;
  13 - 21;
  19 - 21;
  21 - 22;
  12 - 22;
  13 - 22;
  16 - 22;
  19 - 22;
  22 - 23;
  12 - 23;
  13 - 23;
  16 - 23;
  19 - 23;
  21 - 23;
  23 - 24;
  24 - 25;
  25 - 27;
  12 - 27;
  13 - 27;
  16 - 27;
  19 - 27;
  21 - 27;
  22 - 27;
  23 - 27;
  27 - 28;
  12 - 28;
  13 - 28;
  16 - 28;
  19 - 28;
  21 - 28;
  22 - 28;
  23 - 28;
  28 - 29;
  12 - 29;
  13 - 29;
  16 - 29;
  19 - 29;
  21 - 29;
  22 - 29;
  23 - 29;
  27 - 29;
  29 - 30;
  12 - 30;
  13 - 30;
  16 - 30;
  19 - 30;
  21 - 30;
  22 - 30;
  23 - 30;
  27 - 30;
  28 - 30;
  30 - 31;
  31 - 32;
  32 - 33;
  31 - 33;
  33 - 26;
  26 - 34;
  12 - 34;
  13 - 34;
  16 - 34;
  19 - 34;
  21 - 34;
  22 - 34;
  23 - 34;
  27 - 34;
  28 - 34;
  29 - 34;
  30 - 34;
  34 - 35;
  35 - 36;
}

I want to cluster these graphs.I am trying to implement K-Medoids.

How to start with K-Medoid implementation? How can i find distance between two graphs?

Topic graphs clustering

Category Data Science


K-medoids is not designed for graphs since k-medoids relies on Euclidean distance metric.

It would be useful to cluster graphs with graph-based algorithm, such as spectral clustering.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.