pairs to tree

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
I am re-thinking an old graph problem . Any idea of how to build e.g. the
tree

a
b
e
f
c
d
t
t
a
f
a

from the pairs ?

f,a
t,a
d,t
b,e
b,f
a,c
a,d
a,b

Re: pairs to tree

I'm curious: for what class is this a homework problem?

Also, I don't see the specification.  The pairs are
parent,child
and it even appears to be bottom-up.

But sometimes it's shown as transitive, like how
b,e
a,b
resulted in
a
b
e

But
t,a
d,t
does not result in
d
t
a
t
a
is itself a side tree.

--
Tim McDaniel, tmcd@panix.com

Re: pairs to tree

order is not important. pairs are unique. it is about building topology maps.

Re: pairs to tree

On Apr 4, 8:25=A0pm, "George Mpouras"

I have the same problem as Tim to understand your question.
There are even cycles...

t -> a -> d -> t
f -> a -> b -> f

Marc

Re: pairs to tree

I'm usually fond of trimming unneeded text, but for someone on a
newsgroup, trimming ALL context and background is not so good.

I'm sorry, but you did not answer my questions.  Expanding a bit:

But sometimes it's shown as transitive, like how
b,e
a,b
results in
a
b
e

But
t,a
d,t
a,d
does not result in
a
d
t
a
a
d
and
t
a
in two separate trees.  Why?  How is the program supposed to know what
to do?

--
Tim McDaniel, tmcd@panix.com

Re: pairs to tree

<snip>

tsort(1).

You will need to change the output code if you want the graph rather
than the sorted list. I'm sure there are already CPAN modules which will
do this for you.

Ben