xref: /original-bsd/usr.bin/tsort/tsort.1 (revision 3705696b)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This manual is derived from one contributed to Berkeley by
5.\" Michael Rendell of Memorial University of Newfoundland.
6.\" %sccs.include.redist.roff%
7.\"
8.\"     @(#)tsort.1	8.1 (Berkeley) 06/09/93
9.\"
10.Dd
11.Dt TSORT 1
12.Os
13.Sh NAME
14.Nm tsort
15.Nd topological sort of a directed graph
16.Sh SYNOPSIS
17.Nm tsort
18.Op Ar file
19.Sh DESCRIPTION
20.Nm Tsort
21takes a list of pairs of node names representing directed arcs in
22a graph and prints the nodes in topological order on standard output.
23Input is taken from the named
24.Ar file ,
25or from standard input if no file
26is given.
27.Pp
28Node names in the input are separated by white space and there must be an
29even number of nodes.
30.Pp
31Presence of a node in a graph can be represented by an arc from the node
32to itself.
33This is useful when a node is not connected to any other nodes.
34.Pp
35If the graph contains a cycle (and therefore cannot be properly sorted),
36one of the arcs in the cycle is ignored and the sort continues.
37Cycles are reported on standard error.
38.Sh SEE ALSO
39.Xr ar 1
40.Sh HISTORY
41A
42.Nm
43command appeared in
44.At v7 .
45This
46.Nm tsort
47command and manual page are derived from sources contributed to Berkeley by
48Michael Rendell of Memorial University of Newfoundland.
49