Commit f18e7ea3 authored by Alexander Lercher's avatar Alexander Lercher

applied oo

parent ef2f767f
import json
class HyperGraph:
def do():
df_nodes = load_values()
cluster_labels = []
dest_cluster_labels = []
label_values = []
ret_val = init(df_nodes)
def __init__(self):
pass
def classify(self):
df_nodes = self.load_values()
ret_val = self.init(df_nodes)
nodeIds = ret_val['nodeIds']
clusterlabels = ret_val['clusterlabels']
destIds = ret_val['destIds']
clusterlabels = classify_input(nodeIds, clusterlabels)
clusterlabels = self.classify_input(nodeIds, clusterlabels)
labelvals = self.calc_cluster_num(clusterlabels)
labelvals = calc_cluster_num(clusterlabels)
cluster = self.cluster_with_labels(nodeIds, clusterlabels, labelvals)
cluster = cluster_with_labels(nodeIds, clusterlabels, labelvals)
cluster = self.remove_duplicates(cluster)
cluster = remove_duplicates(cluster)
destclusterlabel = self.cluster_dest_ids(labelvals, cluster, destIds)
destclusterlabel = cluster_dest_ids(labelvals, cluster, destIds)
self.cluster_labels = clusterlabels
self.dest_cluster_labels = destclusterlabel
self.labelvals = labelvals
def load_values():
def load_values(self):
with open("mult_in_out_large.json", "r") as json_file:
df_nodes = json.load(json_file)
return df_nodes
def init(df_nodes):
def init(self, df_nodes):
nodeIds = []
clusterlabels = []
destIds = []
......@@ -53,7 +65,7 @@ def init(df_nodes):
'clusterlabels': clusterlabels,
'destIds': destIds}
def classify_input(nodeIds, clusterlabels):
def classify_input(self, nodeIds, clusterlabels):
"""" classifying Inputs"""
"""" Labaling inputs"""
for row in range(len(nodeIds)):
......@@ -81,7 +93,7 @@ def classify_input(nodeIds, clusterlabels):
print("NodeIDs: ", len(nodeIds))
return clusterlabels
def calc_cluster_num(clusterlabels):
def calc_cluster_num(self, clusterlabels):
"""" Calculating the number of clusters"""
labelvals = []
......@@ -99,7 +111,7 @@ def calc_cluster_num(clusterlabels):
return labelvals
def cluster_with_labels(nodeIds, clusterlabels, labelvals):
def cluster_with_labels(self, nodeIds, clusterlabels, labelvals):
"""" clustering Ids according to their labels"""
cluster = []
......@@ -112,7 +124,7 @@ def cluster_with_labels(nodeIds, clusterlabels, labelvals):
return cluster
def remove_duplicates(cluster):
def remove_duplicates(self, cluster):
""" Removing duplicating items in cluster"""
flag = True
......@@ -137,7 +149,7 @@ def remove_duplicates(cluster):
return cluster
def cluster_dest_ids(labelvals, cluster, destIds):
def cluster_dest_ids(self, labelvals, cluster, destIds):
"""" Clustering Destination Ids """
destclusterlabel = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment