Skip to content

Commit

Permalink
add option to customize layout function for export
Browse files Browse the repository at this point in the history
  • Loading branch information
codingfabi committed Dec 27, 2023
1 parent 64bea58 commit 681a77f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hetpy/models/hetGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,18 @@ 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.
Parameters:
--------------
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"}
Expand Down

0 comments on commit 681a77f

Please sign in to comment.