Une mise-à-jour est prévue le 9 juillet entre 13:00 et 14:00. Le service sera inaccessible ou instable pendant cette période. Merci de votre compréhension.

Commit 6130f6cd authored by Fize Jacques's avatar Fize Jacques

ADD reader.pyx

 -- add function to load graph in a elegant way \o/
parent 5282767f
# coding = utf-8
\ No newline at end of file
# coding = utf-8
import sys, os, glob, json, re
import networkx as nx
methods_read_graph={
"gexf":nx.read_gexf,
"gml":nx.read_gml,
"graphml":nx.read_graphml
}
def extract_number(fn):
try:
return int(re.findall("\d+",fn)[-1])
except:
print("No number found !")
return 0
def import_dir(directory,format="gexf",numbered=True):
if not os.path.exists(directory):
raise FileNotFoundError
if not format in methods_read_graph:
raise NotImplementedError("{0} is not implemented !".format(format))
fns = glob.glob(os.path.join(directory, "*.{0}".format(format)))
graphs=[]
if numbered:
n=max([extract_number(fn) for fn in fns])
graphs= [nx.Graph()]*(n+1)
association_map, i = {}, 0
for fn in fns:
if not numbered:
graphs.append(methods_read_graph[format](fn))
association_map[fn]=i
i+=1
else:
graphs[extract_number(fn)]=methods_read_graph[format](fn)
if not numbered:
return association_map,graphs
return graphs
......@@ -47,15 +47,15 @@ extensions = cythonize([makeExtension(name) for name in extNames])
setup(
name="GMatch4py",
description="A module for graph matching",
packages=["gmatch4py"],
packages=["gmatch4py","gmatch4py.helpers"],
ext_modules=extensions,
cmdclass={'build_ext': build_ext},
setup_requires=["numpy","networkx"],
install_requires=["numpy","networkx"],
setup_requires=["numpy","networkx","networkit"],
install_requires=["numpy","networkx","networkit"],
version="0.1"
)
#Clean cpp and compiled file
f=False
f=True
if f:
if os.path.exists("build"):
shutil.rmtree("build")
......
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