Why does tsort not report any loop in this example?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
How does tsort find the order in the following examples?
Why does tsort not report any loop in this example,
$ tsort <<EOF
a b c d c b a b
EOF
a
c
b
d
whereas it does in this one? Thanks.
$ tsort <<EOF
a b c d d c b a
EOF
tsort: -: input contains a loop:
tsort: a
tsort: b
a
b
tsort: -: input contains a loop:
tsort: c
tsort: d
c
d
tsort
add a comment |
up vote
0
down vote
favorite
How does tsort find the order in the following examples?
Why does tsort not report any loop in this example,
$ tsort <<EOF
a b c d c b a b
EOF
a
c
b
d
whereas it does in this one? Thanks.
$ tsort <<EOF
a b c d d c b a
EOF
tsort: -: input contains a loop:
tsort: a
tsort: b
a
b
tsort: -: input contains a loop:
tsort: c
tsort: d
c
d
tsort
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How does tsort find the order in the following examples?
Why does tsort not report any loop in this example,
$ tsort <<EOF
a b c d c b a b
EOF
a
c
b
d
whereas it does in this one? Thanks.
$ tsort <<EOF
a b c d d c b a
EOF
tsort: -: input contains a loop:
tsort: a
tsort: b
a
b
tsort: -: input contains a loop:
tsort: c
tsort: d
c
d
tsort
How does tsort find the order in the following examples?
Why does tsort not report any loop in this example,
$ tsort <<EOF
a b c d c b a b
EOF
a
c
b
d
whereas it does in this one? Thanks.
$ tsort <<EOF
a b c d d c b a
EOF
tsort: -: input contains a loop:
tsort: a
tsort: b
a
b
tsort: -: input contains a loop:
tsort: c
tsort: d
c
d
tsort
tsort
asked Nov 17 at 16:36
Tim
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
There is no loop in your first input. Let's break it down:
a b c d c b a b
Or, putting it in pairs:
- a < b
- c < d
- c < b
- a < b (this one specified twice!)
So you have that both "a" and "c" come before "b" and that "c" also comes before "d". But there are no loops there!
On your second example though, what you have is two direct loops, both a < b, b < a (loop!) and also c < d, d < c (loop!)
Putting these in a graph for visualization (you might want to look into the dot program) might help you visualize these loops easily!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
There is no loop in your first input. Let's break it down:
a b c d c b a b
Or, putting it in pairs:
- a < b
- c < d
- c < b
- a < b (this one specified twice!)
So you have that both "a" and "c" come before "b" and that "c" also comes before "d". But there are no loops there!
On your second example though, what you have is two direct loops, both a < b, b < a (loop!) and also c < d, d < c (loop!)
Putting these in a graph for visualization (you might want to look into the dot program) might help you visualize these loops easily!
add a comment |
up vote
2
down vote
accepted
There is no loop in your first input. Let's break it down:
a b c d c b a b
Or, putting it in pairs:
- a < b
- c < d
- c < b
- a < b (this one specified twice!)
So you have that both "a" and "c" come before "b" and that "c" also comes before "d". But there are no loops there!
On your second example though, what you have is two direct loops, both a < b, b < a (loop!) and also c < d, d < c (loop!)
Putting these in a graph for visualization (you might want to look into the dot program) might help you visualize these loops easily!
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
There is no loop in your first input. Let's break it down:
a b c d c b a b
Or, putting it in pairs:
- a < b
- c < d
- c < b
- a < b (this one specified twice!)
So you have that both "a" and "c" come before "b" and that "c" also comes before "d". But there are no loops there!
On your second example though, what you have is two direct loops, both a < b, b < a (loop!) and also c < d, d < c (loop!)
Putting these in a graph for visualization (you might want to look into the dot program) might help you visualize these loops easily!
There is no loop in your first input. Let's break it down:
a b c d c b a b
Or, putting it in pairs:
- a < b
- c < d
- c < b
- a < b (this one specified twice!)
So you have that both "a" and "c" come before "b" and that "c" also comes before "d". But there are no loops there!
On your second example though, what you have is two direct loops, both a < b, b < a (loop!) and also c < d, d < c (loop!)
Putting these in a graph for visualization (you might want to look into the dot program) might help you visualize these loops easily!
answered Nov 17 at 17:00
Filipe Brandenburger
6,1141625
6,1141625
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482364%2fwhy-does-tsort-not-report-any-loop-in-this-example%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown