TSORT(1)

NAME
tsort - topological sort

SYNOPSIS
tsort [file]

DESCRIPTION
tsort topologically sorts a graph. The graph is read either from file or from standard input. The result is not optimized for any particular usage. Loops are detected and reported to standard error, but does not stop the sort.

The input is a list of edges (vertex pairs), where the edge is directed from the first vertex to the second vertex.

OPTIONS
None.

EXIT STATUS

0   The graph as successfully sorted.

1   The graph as successfully sorted, but contained loops.

> 1 An error occurred.

EXAMPLES

    The input
        a a
        a b
        a c
        a c
        a d
        b c
        c b
        e f
    or equivalently
        a a a b a c a c a d
        b c c b e f
    represents the graph
                  ┌─┐
                  ↓ │
                 ┏━━━┓
          ┌──────┃ a ┃──────┐
          │      ┗━━━┛      │
          │       │ │       │
          ↓       ↓ ↓       ↓
        ┏━━━┓───→┏━━━┓    ┏━━━┓
        ┃ b ┃    ┃ c ┃    ┃ d ┃
        ┗━━━┛←───┗━━━┛    ┗━━━┛
        ┏━━━┓    ┏━━━┓
        ┃ e ┃───→┃ f ┃
        ┗━━━┛    ┗━━━┛

STANDARDS
The tsort utility is compliant with the p1003.1-2013 specification.