Add export and import method for graph #12

Open
opened 2026-06-06 22:02:09 +00:00 by linarphy · 3 comments
Owner

This would allow to load a graph from a file, and to save the graph to a file.

Conversion format ideas:

One possible strategy would be to implement those conversion is to implement a convert(format: ConversionFormat) method to Connection, 'Node' and Graph. There is one ConversionFormat by conversion format. Each one implements a convert_graph(graph: Graph) -> str, convert_node(node: Node) -> str and convert_connection(connection: Connection) -> str. The convert method will then call format.convert_connection(self) (for a Connection here).

Should we implement a way for user to implement custom conversion ? If yes, this method won’t work, or each one should add their own ConversionFormat inherited class. Maybe they could customize a specific conversion format by inheriting from the specific inherited ConversionFormat (A user add a FooConversionFormat class which inherit from DotConversionFormat which inherit from ConversionFormat) ?

Don’t know if this is good to have to use custom classes for custom Node/Graph/Connection.

This would allow to load a graph from a file, and to save the graph to a file. Conversion format ideas: - dot (https://graphviz.org/doc/info/lang.html) - mermaid (https://mermaid.ai/open-source/intro/syntax-reference.html) - plantUML (https://plantuml.com) - RDF/XML (https://w3c.github.io/rdf-xml/spec/) - RDF/TURTLE (https://w3c.github.io/rdf-turtle/spec/) One possible strategy would be to implement those conversion is to implement a `convert(format: ConversionFormat)` method to `Connection`, 'Node' and `Graph`. There is one `ConversionFormat` by conversion format. Each one implements a `convert_graph(graph: Graph) -> str`, `convert_node(node: Node) -> str` and `convert_connection(connection: Connection) -> str`. The `convert` method will then call `format.convert_connection(self)` (for a `Connection` here). Should we implement a way for user to implement custom conversion ? If yes, this method won’t work, or each one should add their own ConversionFormat inherited class. Maybe they could customize a specific conversion format by inheriting from the specific inherited ConversionFormat (A user add a FooConversionFormat class which inherit from DotConversionFormat which inherit from ConversionFormat) ? Don’t know if this is good to have to use custom classes for custom Node/Graph/Connection.
Author
Owner

Other format to consider:

  • GraphML
  • GML
Other format to consider: - GraphML - GML
Author
Owner

Maybe:

  • Graphol
Maybe: - Graphol
Author
Owner

Fallback format created. Mermaid state machine done.
I will first add tests for the fallback format.

Fallback format created. Mermaid state machine done. I will first add tests for the fallback format.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
linarphy/galaxy-graph#12
No description provided.