tsort(1) -l (longest cycle) clarification

Fernando Apesteguía fernando.apesteguia at gmail.com
Thu Jul 23 09:55:48 UTC 2020


Hi there,

I'm having some doubts about the -l flag in tsort(1). According to the
man page, it should show the longest cycle in the graph. Assuming we
have a file called graph with the following contents:

A B
A D
B C
C A
D E
E F
F E

This graph has two cycles one involving two nodes and the other
involving three nodes:

$ tsort graph
tsort: cycle in data
tsort: E
tsort: F
F
tsort: cycle in data
tsort: A
tsort: B
tsort: C
C
A
D
B
E

When using -q, tsort(1) does not show information about cycles as expected:

$ tsort -q graph
F
C
A
D
B
E

Using -l shows the exact same output as not using options at all:

$ tsort -l graph
tsort: cycle in data
tsort: E
tsort: F
F
tsort: cycle in data
tsort: A
tsort: B
tsort: C
C
A
D
B
E

So what's -l supposed to do? Shouldn't it at least mark one of the
cycles and say "This one is the longest"? Technically, it shows the
longest cycle, but it shows other cycles as well so I don't see the
use of this.

Cheers


More information about the freebsd-hackers mailing list