From 681a77fcc1de9d76785bbcbf6de1dc69b33197f3 Mon Sep 17 00:00:00 2001 From: codingfabi Date: Wed, 27 Dec 2023 16:07:47 +0100 Subject: [PATCH] add option to customize layout function for export --- hetpy/models/hetGraph.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hetpy/models/hetGraph.py b/hetpy/models/hetGraph.py index bfea1d7..804d598 100644 --- a/hetpy/models/hetGraph.py +++ b/hetpy/models/hetGraph.py @@ -447,7 +447,7 @@ def get_edges_of_type(self, type : str) -> List[Edge]: # util function for graph file storage - def export_to_json(self, filepath: str): + def export_to_json(self, filepath: str, layout_function='auto'): """ Exports the graph to a json file to share or expose. @@ -455,8 +455,10 @@ def export_to_json(self, filepath: str): -------------- filepath : str The filepath where the resulting json data shall be stored. + layout_function : str + The layout after which the nodes should be positioned. All iGraph layout functions are valid. Defaults to 'auto'. """ - layout = self.graph.layout(layout='auto') + layout = self.graph.layout(layout=layout_function) edges_json = [] for index, edge in enumerate(self.edges): edge_dict = {e: getattr(edge, e) for e in dir(edge) if not e.startswith('__') and e != "nodes"}