Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Aug 2020 17:37:56 +0000 (UTC)
From:      =?UTF-8?Q?Fernando_Apestegu=c3=ada?= <fernape@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364976 - head/usr.bin/tsort
Message-ID:  <202008301737.07UHbu8A093294@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fernape (ports committer)
Date: Sun Aug 30 17:37:56 2020
New Revision: 364976
URL: https://svnweb.freebsd.org/changeset/base/364976

Log:
  tsort(1): Add EXAMPLES section
  
  Add a couple of simple examples to the man page
  
  Approved by:	manpages (gbe@)
  Differential Revision:	https://reviews.freebsd.org/D25883

Modified:
  head/usr.bin/tsort/tsort.1

Modified: head/usr.bin/tsort/tsort.1
==============================================================================
--- head/usr.bin/tsort/tsort.1	Sun Aug 30 17:13:04 2020	(r364975)
+++ head/usr.bin/tsort/tsort.1	Sun Aug 30 17:37:56 2020	(r364976)
@@ -31,7 +31,7 @@
 .\"     @(#)tsort.1	8.3 (Berkeley) 4/1/94
 .\" $FreeBSD$
 .\"
-.Dd December 27, 2006
+.Dd August 30, 2020
 .Dt TSORT 1
 .Os
 .Sh NAME
@@ -75,6 +75,71 @@ This is primarily
 intended for building libraries, where optimal ordering is not critical,
 and cycles occur often.
 .El
+.Sh EXAMPLES
+Assuming a file named
+.Pa dag
+with the following contents representing a directed acyclic graph:
+.Bd -literal -offset indent
+A B
+A F
+B C
+B D
+D E
+.Ed
+.Pp
+Sort the nodes of the graph:
+.Bd -literal -offset indent
+$ tsort dag
+A
+F
+B
+D
+C
+E
+.Ed
+.Pp
+White spaces and new line characters are considered equal.
+This file for example is considered equal to the one we defined before:
+.Bd -literal -offset indent
+$ cat dga
+A B A F B C B D D E
+.Ed
+.Pp
+Assume we add a new directed arc from D to A creating a cycle:
+.Bd -literal -offset indent
+A B
+A F
+B C
+B D
+D E
+D A
+.Ed
+.Pp
+Ordering the graph detects the cycle:
+.Bd -literal -offset indent
+$ tsort dag
+tsort: cycle in data
+tsort: A
+tsort: B
+tsort: D
+D
+E
+A
+F
+B
+C
+.Ed
+.Pp
+Same as above but silencing the warning about the cycle:
+.Bd -literal -offset indent
+$ tsort -q dag
+D
+E
+A
+F
+B
+C
+.Ed
 .Sh SEE ALSO
 .Xr ar 1
 .Sh HISTORY



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008301737.07UHbu8A093294>