xref: /original-bsd/usr.bin/tsort/tsort.1 (revision 3413c235)
1.\" Copyright (c) 1990, 1993, 1994
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.\"
7.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)tsort.1	8.3 (Berkeley) 04/01/94
10.\"
11.Dd
12.Dt TSORT 1
13.Os
14.Sh NAME
15.Nm tsort
16.Nd topological sort of a directed graph
17.Sh SYNOPSIS
18.Nm tsort
19.Op Fl l
20.Op Ar file
21.Sh DESCRIPTION
22.Nm Tsort
23takes a list of pairs of node names representing directed arcs in
24a graph and prints the nodes in topological order on standard output.
25Input is taken from the named
26.Ar file ,
27or from standard input if no file
28is given.
29.Pp
30Node names in the input are separated by white space and there must
31be an even number of node pairs.
32.Pp
33Presence of a node in a graph can be represented by an arc from the node
34to itself.
35This is useful when a node is not connected to any other nodes.
36.Pp
37If the graph contains a cycle (and therefore cannot be properly sorted),
38one of the arcs in the cycle is ignored and the sort continues.
39Cycles are reported on standard error.
40.Pp
41The options are as follows:
42.Bl -tag -width Ds
43.It Fl l
44Search for and display the longest cycle.
45Can take a very long time.
46.El
47.Sh SEE ALSO
48.Xr ar 1
49.Sh HISTORY
50A
51.Nm
52command appeared in
53.At v7 .
54This
55.Nm tsort
56command and manual page are derived from sources contributed to Berkeley by
57Michael Rendell of Memorial University of Newfoundland.
58