How to use the command "circo" (with examples)
The “circo” command is a part of the “graphviz” software package and is used to render an image of a circular network graph from a graphviz file. It supports various layouts such as dot, neato, twopi, circo, fdp, sfdp, osage, and patchwork. This article will illustrate different use cases of the “circo” command.
Use case 1: Render a png
image with a filename based on the input filename and output format (uppercase -O):
Code:
circo -T png -O path/to/input.gv
Motivation: In this use case, we want to render a circular network graph from a graphviz file and save it as a PNG image. We use the uppercase -O flag followed by the desired output file path. The filename will be based on the input filename and output format.
Explanation:
circo
: The command itself.-T png
: Specifies the output file format as PNG.-O path/to/input.gv
: Specifies the output file path. The filename will be based on the input filename and output format.
Example Output: The command will render a circular network graph from the input graphviz file and save it as a PNG image with a filename based on the input filename and output format.
Use case 2: Render a svg
image with the specified output filename (lowercase -o):
Code:
circo -T svg -o path/to/image.svg path/to/input.gv
Motivation: In this use case, we want to render a circular network graph from a graphviz file and save it as an SVG image. We use the lowercase -o flag followed by the desired output file path. We explicitly specify the output filename instead of relying on the input filename.
Explanation:
circo
: The command itself.-T svg
: Specifies the output file format as SVG.-o path/to/image.svg
: Specifies the output file path and filename.path/to/input.gv
: Specifies the input graphviz file.
Example Output: The command will render a circular network graph from the input graphviz file and save it as an SVG image with the specified output filename.
Use case 3: Render the output in ps
, pdf
, svg
, fig
, png
, gif
, jpg
, json
, or dot
format:
Code:
circo -T format -O path/to/input.gv
Motivation: In this use case, we want to render a circular network graph from a graphviz file and save it in multiple file formats. We can specify the desired output format using the -T flag followed by the format name (e.g., ps, pdf, svg, fig, png, gif, jpg, json, or dot). The uppercase -O flag is used to specify the output file path.
Explanation:
circo
: The command itself.-T format
: Specifies the desired output format (e.g., ps, pdf, svg, fig, png, gif, jpg, json, or dot).-O path/to/input.gv
: Specifies the output file path.
Example Output: The command will render a circular network graph from the input graphviz file and save it in the specified output format.
Use case 4: Render a gif
image using stdin
and stdout
:
Code:
echo "digraph {this -> that} " | circo -T gif > path/to/image.gif
Motivation: In this use case, we want to render a circular network graph from a graphviz file provided via stdin and save it as a GIF image. This can be useful when we have the graphviz file content in a variable or want to generate the graph dynamically.
Explanation:
echo "digraph {this -> that}"
: Provides the graphviz file content as input via stdin.|
: Redirects the output of the previous command as input to the next command.circo
: The command itself.-T gif
: Specifies the output file format as GIF.> path/to/image.gif
: Redirects the output to the specified file path.
Example Output: The command will render a circular network graph from the provided graphviz file content and save it as a GIF image at the specified file path.
Use case 5: Display help:
Code:
circo -?
Motivation: In this use case, we want to display help and usage information for the “circo” command. This can be useful when we need to refer to the available options, arguments, and syntax of the command.
Explanation:
circo
: The command itself.-?
: Displays help and usage information.
Example Output: The command will display the help and usage information for the “circo” command.
Conclusion:
In this article, we explored different use cases of the “circo” command from the “graphviz” software package. We learned how to render circular network graphs from graphviz files and save them in various image formats. The “circo” command provides flexibility in specifying output file paths, filenames, and formats, making it a versatile tool for visualizing network graphs.