Created
December 8, 2024 22:03
-
-
Save umairsd/cf557ebdcc71c243499275bc789efc3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def to_dot(self) -> str: | |
| """Convert the type map to DOT language format.""" | |
| dot_lines = ['digraph RemodelTypes {'] | |
| dot_lines.append(' // Node styling') | |
| dot_lines.append(' node [shape=box, style=filled, fillcolor=lightblue];') | |
| dot_lines.append(' edge [color=gray];') | |
| dot_lines.append('') | |
| # Add nodes | |
| dot_lines.append(' // Nodes') | |
| for type_name in self.type_map.keys(): | |
| dot_lines.append(f' "{type_name}";') | |
| dot_lines.append('') | |
| # Add edges | |
| dot_lines.append(' // Edges') | |
| for type_name, field_types in self.type_map.items(): | |
| for field_type in field_types: | |
| dot_lines.append(f' "{type_name}" -> "{field_type}";') | |
| dot_lines.append('}') | |
| return '\n'.join(dot_lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment