GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PTSORT(1) FreeBSD General Commands Manual PTSORT(1)

ptsort
Prioritized topological sort

ptsort [-Ddpqsv] [-o output] [input ...]

The ptsort utility takes a directed acyclic graph of nodes as input and outputs the nodes in topological order. Unlike tsort(1), the ptsort utility allows nodes to be given a numeric priority. Priorities are propagated along edges so that each node's priority is greater than the priority of all its successors. Thus, it is possible to boost a specific node so that it, and all its predecessors, will be listed ahead of other unrelated nodes.

The following options are available:

Sort the output by depth first instead of priority first.
Include each node's depth in the output.
Include each node's priority in the output.
Quiet mode. Do not warn about cycles in the input.
Strict mode. Cycles in the input will cause ptsort to terminate with an exit code of 3.
Verbose mode. Show detailed information while building and traversing the graph.

The ptsort utility takes its input either from the files listed on the command line or, if no files were specified, from the standard input. All input is read into the same graph before processing.

Each input line contains either two names or a name and a decimal integer, separated by any amount of whitespace. Any amount of leading or trailing whitespace is permitted. Names are arbitrary non-empty sequences of up to 255 printable, non-whitespace ASCII characters. It is strictly speaking possible, but not a good idea, for a node's name to consist entirely of digits.

If the line contains two names, the effect is to insert a directed edge into the graph going from the first (predecessor) node to the second (successor) node. Either or both nodes are created if they do not already exist. If both names are identical, no edge is inserted, but the node is still created unless it already exists.

If the line contains a name and a number, the effect is to raise the priority of that node to the given number, unless it is already higher. The node will be created if it does not already exist.

Blank lines in the input are ignored.

Any error in the input will cause ptsort to print an error message which includes the offending line and terminate with an exit code of 2.

If no error occurred, the ptsort utility ouputs one line for each node in the graph, consisting of the node's name optionally preceded by its depth (if the -d option was specified) and / or priority (if the -p option was specified). By default, the list is sorted in decreasing order of priority, then depth, then name. If the -D option was specified, it is sorted in decreasing order of depth, then priority, then name.

If an error occurred, the ptsort utility exits with one of the following codes:
1
An error occurred while opening or reading from an input file or while trying to allocate memory.
2
A syntax error was encountered in the input.
3
A cycle was detected while running in strict mode.

Otherwise, it exits with code 0.

tsort(1)

The ptsort utility and this manual page were written by Dag-Erling Smørgrav <des@des.no>.

The ptsort utility uses a completely different algorithm than the similar tsort(1) and may therefore produce different (but toplogically equivalent) output when given the same input.

The ptsort utility should probably have been named klatch, but the author has no imagination or appreciation for the literary arts.

September 4, 2017 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.