From 945f487a08b643392a5d5918c631640b9a0e4605 Mon Sep 17 00:00:00 2001 From: 20001LastOrder Date: Tue, 3 Nov 2020 22:52:26 -0500 Subject: add realistic solver --- .../metrics_plot/utils/GraphType.py | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py (limited to 'Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py') diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py new file mode 100644 index 00000000..48d96ccc --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py @@ -0,0 +1,46 @@ +import readCSV as reader +import constants +import numpy as np + +# graph stats for a collection of graphs +class GraphCollection: + + # init with path contrain files and number of files to read reader is imported from (readCSV) + def __init__(self, path, number, name, shouldShuffle = True): + self.out_ds = [] + self.nas = [] + self.mpcs = [] + self.nts = [] + self.name = name + self.tccs = [] + self.violations = [] + models = reader.readmultiplefiles(path, number, shouldShuffle) + print(len(models)) + self.size = len(models) + for i in range(len(models)): + contents, out_d, na, mpc = reader.getmetrics(models[i]) + self.out_ds.append(out_d) + self.nas.append(na) + self.mpcs.append(mpc) + if(constants.Node_TYPE_KEY in contents): + self.nts.append(contents[constants.Node_TYPE_KEY]) + if(constants.TCC_VALUE in contents): + self.tccs.append(contents[constants.TCC_VALUE]) + if(constants.VIOLATION in contents): + self.violations.append(contents[constants.VIOLATION][0]) + +#Graph stat for one graph +class GraphStat: + # init with teh file name of the stat + def __init__(self, filename): + contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename) + self.numNodes = np.array(contents[constants.NUMBER_NODES]) + if constants.STATE_ID in contents: + self.id = (contents[constants.STATE_ID])[0] + if constants.Node_TYPE_KEY in contents: + self.nodeTypeStat = contents[constants.Node_TYPE_KEY] + if constants.VIOLATION in contents: + self.violations = int(contents[constants.VIOLATION][0]) + if(constants.TCC_VALUE_KEY in contents): + self.tcc = contents[constants.TCC_VALUE_KEY] + -- cgit v1.2.3-54-g00ecf