Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2020 12:54:51 +0200
From:      =?UTF-8?Q?Fernando_Apestegu=C3=ADa?= <fernando.apesteguia@gmail.com>
To:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   tsort(1) -l (longest cycle) clarification
Message-ID:  <CAGwOe2Yrnidv5LCho1K8Cz%2BUEOzonHXQbVt9snexn3B9Rmz0iQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGwOe2Yrnidv5LCho1K8Cz%2BUEOzonHXQbVt9snexn3B9Rmz0iQ>