def computeFeatures(self, G, features_nx, features_nk): if("effective_graph_resistance" in features_nx or "nb_spanning_trees" in features_nx or "algebraic_connectivity" in features_nx): if(self.params["verbose"]): print("Computing laplacian_eigenvalues") s = time.time() self.eigenvalues["laplacian"] = np.real(nx.laplacian_spectrum(G)) if(self.params["verbose"]): print("Finish laplacian_eigenvalues (%s)" % (timeFormat(time.time()-s))) if("largest_eigenvalue" in features_nx or "symmetry_ratio" in features_nx or "natural_connectivity" in features_nx): if(self.params["verbose"]): print("Computing adjacency_eigenvalues") s = time.time() self.eigenvalues["adjacency"] = np.real(nx.adjacency_spectrum(G)) if(self.params["verbose"]): print("Finish adjacency_eigenvalues (%s)" % (timeFormat(time.time()-s))) if("weighted_spectrum_3" in features_nx or "weighted_spectrum_4" in features_nx): if(self.params["verbose"]): print("Computing normalized_laplacian_eigenvalues") s = time.time() self.eigenvalues["normalized_laplacian"] = np.real(nx.normalized_laplacian_spectrum(G)) if(self.params["verbose"]): print("Finish normalized_laplacian_eigenvalues (%s)" % (timeFormat(time.time()-s))) return(NodesFeatures.computeFeatures(self, G, features_nx, features_nk))
def execute(self): timeAtStart = time.time() self.log("###############") self.log("# Transform") self.log("###############") self.log("Folder: {}".format(self.outFolder)) self.printParams() if(self.filePath!=None and self.exists() and self.params["SkipIfExist"]): self.log("Data exists, skipped") else: self.init() self.compute() self.transformedData = self.postProcess(self.transformedData) self.log("Computation time: " + utils.timeFormat(time.time()-timeAtStart)) if(self.filePath!=None): self.save() if(self.params["Gzip"]): utils.gzipFile(self.filePath, remove=True) self.filePath += ".gz" self.log("Transformed data saved to: " + self.filePath) if(os.path.exists(self.dataFile+".gz")): os.remove(self.dataFile) if(os.path.exists(self.primingFile+".gz")): if(self.loadPrimingData): os.remove(self.primingFile)
def execute(self): timeAtStart = time.time() self.log("#################") self.log("# Route Snapshot") self.log("#################") if (type(self.updates) == str): self.log("Updates file: " + self.updates) else: self.log("Nb. of updates: " + str(len(self.updates))) self.log("Nb. of prefix in initial route snapshot: " + str(len(self.routes))) self.buildRoutesSnapshot() self.log("Computation time: " + utils.timeFormat(time.time() - timeAtStart)) self.log("Nb. of prefix in route snapshot: " + str(len(self.routes.keys()))) if (self.filePath != None): self.save() self.log("Route snapshot saved to: " + self.filePath)
def execute(self): timeAtStart = time.time() self.log("###############") self.log("# Updates dump") self.log("###############") self.log("Start time: " + str(self.startTime)) self.log("End time: " + str(self.endTime)) self.log("Duration: " + utils.timeFormat(self.endTime - self.startTime)) self.printParams() self.startStream() self.buildUpdatesDump() self.log("Computation time: " + utils.timeFormat(time.time() - timeAtStart)) self.log("Updates dump saved to: " + self.filePath)
def run(function, results, key, logFiles, verbose, *args): if (verbose): printAndLog("Start:%s" % (key), logFiles) s = time.time() try: results[key] = function(*args) except Exception as e: print("Error with feature: " + key) raise e if (verbose): printAndLog("End:%s (%s)" % (key, timeFormat(time.time() - s)), logFiles)