Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lblA, lblB = line.split()
if lblA in lbl2idx and lblB in lbl2idx:
idxA, idxB = (lbl2idx[i] for i in line.split())
# always go from smaller -> larger, helps merge
if(idxA > idxB):
(idxA, idxB) = (idxB, idxA)
if idxA not in problem:
problem[idxA] = []
problem[idxA].append(idxB)
if verbose:
print("Loaded ", count, " prob pairs.")
print("Grouped into ", len(problem), " query groups.")
print("Constructing network from ", edgePath)
graph = nk.readGraph(edgePath, nk.Format.EdgeListSpaceZero)
outLock = Lock()
outFile = open(outPath, "w")
with ThreadPool() as pool:
pool.map(runProbGroup, problem.items())
outFile.close()
def graphMeta(graphNames, graphDir, fileEnding=".gml.graph", graphFormat=networkit.Format.GML):
if not have_pandas:
raise MissingDependencyError("pandas")
meta = []
for name in graphNames:
info("loading {name}".format(**locals()))
G = networkit.readGraph(os.path.join(graphDir, "{0}{1}".format(name, fileEnding)), graphFormat)
(n, m) = G.size()
meta.append({"name" : name, "n" : n, "m" : m})
info("done")
return pandas.DataFrame(meta, columns=["name", "n", "m"])
"""
# if no custom config is given, use a preconfigured config according to preset name
if not config:
config = Config.createConfig(preset)
if not os.path.isdir(outputDir):
os.mkdir(outputDir)
for (dirpath, dirnames, filenames) in os.walk(inputDir):
for filename in filenames:
file = dirpath + "/" + filename
if fnmatch.fnmatch(filename, filePattern):
Profile.verbosePrint("\n[ " + file + " ]")
try:
G = kit.readGraph(file, graphFormat)
try:
pf = Profile.create(
G,
config = config
)
Profile.verbosePrint("");
pf.output(
outputType = outputType,
directory = outputDir,
style = style,
color = color,
parallel = parallel
)
except Exception as e:
Profile.verbosePrint("=> an error occured: {0} of type {1}".format(e, type(e)))
Profile.verbosePrint(traceback.format_exc())
def loadGraph(self, path, graphFormat=networkit.Format.GML):
with Timer() as t:
G = networkit.readGraph(path, graphFormat)
debug("reading {path} took {t.elapsed} s".format(**locals()))
return G