Skip to content

Instantly share code, notes, and snippets.

@umairsd
Created December 8, 2024 22:03
Show Gist options
  • Select an option

  • Save umairsd/cf557ebdcc71c243499275bc789efc3b to your computer and use it in GitHub Desktop.

Select an option

Save umairsd/cf557ebdcc71c243499275bc789efc3b to your computer and use it in GitHub Desktop.
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