Skip to content

Drawing Relationship Diagrams with Graphviz

A way to draw relationship diagrams using code.

Background

Graphviz is a great tool for drawing relationship diagrams. It has a fundamental difference from Visio: Graphviz generates graphs with automatic layout, eliminating the need for manual adjustment of element positions. When a relationship network becomes complex, automatic layout can minimize crossing lines.

Installation

I found a useful online editor: GraphvizOnline which supports real-time rendering and exporting to formats such as .png and .svg.

For macOS installation: brew install graphviz

Drawing Process

  1. Create a new xxx.dot file.
  2. Edit the .dot document.
  3. Switch to the directory where the file is located, and export it: dot xxx.dot -T png -o xxx.png

Simple Syntax

graph graph_name {
  A--B[label="relationship"]
}

Summary

Automatic layout is the essence of Graphviz. Similar to how I used Markdown syntax to directly generate slides, these tools standardize content, allowing people to focus more on the content itself rather than the form and layout.

References and Acknowledgements

Original: https://wiki-power.com/ This post is protected by CC BY-NC-SA 4.0 agreement, should be reproduced with attribution.

This post is translated using ChatGPT, please feedback if any omissions.