# pairs to tree

Discussion in 'Perl Misc' started by George Mpouras, Apr 4, 2012.

1. ### George MpourasGuest

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

George Mpouras, Apr 4, 2012

2. ### Tim McDanielGuest

In article <jlho10\$49i\$>,
George Mpouras <> wrote:
>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

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,

Tim McDaniel, Apr 4, 2012

3. ### George MpourasGuest

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

George Mpouras, Apr 4, 2012
4. ### Tim McDanielGuest

In article <jlhrbs\$p5o\$>,
Tim McDaniel <> wrote:
>In article <jlho10\$49i\$>,
>George Mpouras <> wrote:
>>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

>
>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.

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

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,

Tim McDaniel, Apr 5, 2012
5. ### Marc GirodGuest

On Apr 4, 8:25 pm, "George Mpouras"
<> wrote:
> order is not important. pairs are unique. it is about building topology maps.

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

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

Marc

Marc Girod, Apr 11, 2012