From b34cdd88bcea3f1f7ad4150058b9fc211372e4a7 Mon Sep 17 00:00:00 2001 From: Etienne Doumazane Date: Fri, 22 Nov 2024 07:26:52 +0100 Subject: [PATCH] IMPROVEMENT: Enables kwargs that can be passed to graph_tool.load_graph for faster graph loading --- ClearMap/Analysis/Graphs/GraphGt.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ClearMap/Analysis/Graphs/GraphGt.py b/ClearMap/Analysis/Graphs/GraphGt.py index 3ee9dd94..e926d711 100755 --- a/ClearMap/Analysis/Graphs/GraphGt.py +++ b/ClearMap/Analysis/Graphs/GraphGt.py @@ -1438,9 +1438,27 @@ def copy(self): return Graph(name = copy.copy(self.name), base = self.base.copy()) -def load(filename): - g = gt.load_graph(filename); - return Graph(base = g); +def load(filename, ignore_vp=None, ignore_ep=None, ignore_gp=None): + """Read graph from file. + + Arguments + --------- + filename : str + Path to the GT file. + ignore_vp : list + Vertex properties that will be ignored. + ignore_ep : list + Edge properties that will be ignored. + ignore_gp : list + Graph properties that will be ignored. + + Returns + ------- + graph : Graph + The graph as a Graph object. + """ + g = gt.load_graph(filename, ignore_vp=ignore_vp, ignore_ep=ignore_ep, ignore_gp=ignore_gp) + return Graph(base=g) def save(filename, graph): graph.save(filename);