LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

acyclic

make a directed graph acyclic

TLDR

Output a copy of the graph with enough edges reversed to make it acyclic
$ acyclic [graph.dot]
copy
Write the acyclic result to a file
$ acyclic -o [output.dot] [graph.dot]
copy
Test only whether the graph is acyclic (no output, check exit status)
$ acyclic -nv [graph.dot]
copy

SYNOPSIS

acyclic [-nv?] [-o outfile] [file]

DESCRIPTION

acyclic is a Graphviz filter that takes a directed graph as input and outputs a copy of the graph with sufficient edges reversed to make the graph acyclic. Each reversed edge inherits all of the attributes of the original edge. By default the program reads from stdin and writes to stdout; an optional file argument specifies where the input graph is stored.This tool is useful for preprocessing graphs before layout algorithms that require acyclic input, or for verifying dependency graphs where cycles would indicate errors. The exit status reports whether the input was acyclic, contained a cycle, or was undirected.

PARAMETERS

-n

Produce no output; the return value indicates whether the graph is acyclic.
-v
Print information about whether the file is acyclic, has a cycle, or is undirected.
-o outfile
Write output to the specified file instead of stdout.
-?
Print usage information.

RETURN CODES

acyclic returns 0 if the graph is acyclic, 1 if the graph has a cycle, 2 if the graph is undirected, and 255 if there are any errors.

CAVEATS

Only works with directed graphs in DOT format. acyclic makes a graph acyclic by reversing edges, never by removing them. If the graph is strict and contains a cycle of length 2, the attributes of the reversed edge are lost. Some edge attributes are non-symmetric (referring to either the head or tail node) and are not switched when an edge is reversed.

HISTORY

acyclic is part of the Graphviz project, developed at AT&T Labs Research starting in 1991. The tool was included to support preprocessing of graphs for hierarchical layout algorithms like dot, which require acyclic input graphs.

SEE ALSO

dot(1), tred(1), gc(1), gvpr(1), gvcolor(1), ccomps(1), sccmap(1)

RESOURCES

Copied to clipboard
Kai