pic2graph
Convert image data to graph data
SYNOPSIS
pic2graph [ options ] [ files ]
PARAMETERS
-G
Use default graph attributes for the output dot graph.
-g
Use default node attributes for the output dot nodes.
-l
Layout the generated graph as a simple list. This option typically affects how node names are assigned and how they might be connected implicitly.
-n
Process pic names as dot nodes. This allows direct mapping of pic object names to dot node identifiers.
-p
Output the processed pic code instead of dot code. Useful for debugging or inspecting the internal representation before dot conversion.
-S
Suppress the outer digraph or graph boilerplate from the output. This is useful when embedding the generated dot code within a larger dot file.
-Pname
Set the default node prefix to name. This prefix is used for automatically generated node names.
-Nname
Set the default node name to name. This can be used to assign a common name to nodes created without explicit names.
-Ename
Set the default edge name to name. Similar to -N, but for edges.
DESCRIPTION
The pic2graph command is a utility from the Graphviz suite designed to translate text-based diagram descriptions written in the pic language into the dot language. pic is a widely used language for drawing diagrams, particularly within the troff/groff typesetting system. While pic is very versatile, pic2graph focuses on extracting and converting graph-like structures (nodes and edges).
It interprets pic objects such as box, circle, ellipse, line, and arrow, transforming them into corresponding dot nodes and edges. This allows users to leverage the powerful layout algorithms of Graphviz (like dot, neato, etc.) to render complex diagrams that were originally described in pic. The output dot file can then be processed by other Graphviz tools to generate visual representations in various formats (e.g., SVG, PNG, PDF).
CAVEATS
pic2graph is not a full-fledged pic interpreter. It specifically targets graph-like structures and may not correctly translate complex pic diagrams involving arbitrary shapes, complex text positioning, or advanced pic features that do not map directly to dot graph constructs. It's best suited for converting structural diagrams into Graphviz's format for layout and rendering.
TYPICAL WORKFLOW
A common workflow involves creating a pic file, then converting it to dot using pic2graph, and finally rendering the dot file into an image:
$ pic2graph input.pic > output.dot
$ dot -Tpng output.dot > output.png
This allows users to combine the descriptive power of pic with the sophisticated layout capabilities of Graphviz.
INPUT FORMAT
The input to pic2graph is a file (or standard input) containing pic language commands. It expects a subset of pic constructs that describe objects and their connections, suitable for translation into a node-and-edge graph representation.
HISTORY
pic2graph is part of the open-source Graphviz (Graph Visualization Software) project, which originated at Bell Labs. Graphviz tools, including pic2graph, were developed to provide flexible and powerful methods for visualizing structural information described in text-based formats. Its development is ongoing, maintained by the Graphviz community.