digraph_writer module
- class py_amr2fred.digraph_writer.DigraphWriter
Bases:
objectA utility class for converting nodes and RDF graphs into Graphviz DOT format and generating graphical representations.
This class provides methods to translate hierarchical structures of Node objects into the DOT language, allowing for visualization as PNG or SVG images. Additionally, it supports RDF graphs by generating DOT representations and linking nodes accordingly.
- static check_visibility(root: Node) Node
Update the visibility status of nodes in the graph.
This method iterates through the node hierarchy and removes nodes marked as invisible.
- static graph_to_digraph(graph: Graph, not_visible_graph: Graph | None = None) str
Convert an RDF graph into DOT graph format.
This method processes the RDF triples and translates them into DOT representation, applying styles based on specific prefixes.
- Parameters:
graph (Graph) – The RDF graph to be converted.
not_visible_graph (Graph, optional) – An optional graph containing hidden triples to be excluded.
- Returns:
A string in DOT format representing the RDF graph.
- Return type:
- static node_to_digraph(root: Node)
Convert a root Node into DOT graph format.
This method translates a given hierarchical node structure into the Graphviz DOT language.
- static to_digraph(root: Node) str
Recursively generate a DOT representation of a Node and its connected sub-nodes.
Nodes are styled based on their properties, such as malformed status and specific prefixes.
- static to_png(root: Node | Graph, not_visible_graph: Graph | None = None) IO | str
Generate a PNG image of the graph representation.
If Graphviz is installed, this method returns an image file of the translated root node or RDF graph. If Graphviz is not installed, it returns the DOT representation as a string.