sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

tsort.1 (1467B)


      1 .Dd 2016-02-16
      2 .Dt TSORT 1
      3 .Os sbase
      4 .Sh NAME
      5 .Nm tsort
      6 .Nd topological sort
      7 .Sh SYNOPSIS
      8 .Nm
      9 .Op Ar file
     10 .Sh DESCRIPTION
     11 .Nm
     12 topologically sorts a graph. The graph is read
     13 either from
     14 .Ar file
     15 or from standard input. The result is not optimized
     16 for any particular usage. Loops are detected and
     17 reported to standard error, but does not stop the sort.
     18 .Pp
     19 The input is a list of edges (vertex pairs), where
     20 the edge is directed from the first vertex to the
     21 second vertex.
     22 .Sh OPTIONS
     23 None.
     24 .Sh EXIT STATUS
     25 .Bl -tag -width Ds
     26 .It 0
     27 The graph as successfully sorted.
     28 .It 1
     29 The graph as successfully sorted, but contained loops.
     30 .It > 1
     31 An error occurred.
     32 .El
     33 .Sh EXAMPLES
     34 .Bd -literal -offset left
     35 The input
     36 
     37     a a
     38     a b
     39     a c
     40     a c
     41     a d
     42     b c
     43     c b
     44     e f
     45 
     46 or equivalently
     47 
     48     a a a b a c a c a d
     49     b c c b e f
     50 
     51 represents the graph
     52 
     53               ┌─┐
     54               ↓ │
     55              ┏━━━┓
     56       ┌──────┃ a ┃──────┐
     57       │      ┗━━━┛      │
     58       │       │ │       │
     59       ↓       ↓ ↓       ↓
     60     ┏━━━┓───→┏━━━┓    ┏━━━┓
     61     ┃ b ┃    ┃ c ┃    ┃ d ┃
     62     ┗━━━┛←───┗━━━┛    ┗━━━┛
     63 
     64     ┏━━━┓    ┏━━━┓
     65     ┃ e ┃───→┃ f ┃
     66     ┗━━━┛    ┗━━━┛
     67 .Ed
     68 .Sh STANDARDS
     69 The
     70 .Nm
     71 utility is compliant with the
     72 .St -p1003.1-2013
     73 specification.