Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: generating a Tree from Array and find the best way

by ultibuzz (Monk)
on Apr 06, 2006 at 21:55 UTC ( #541748=note: print w/ replies, xml ) Need Help??


in reply to Re: generating a Tree from Array and find the best way
in thread generating a Tree from Array and find the best way

thx for the hint im now reading the Graph::Easy::Parser, and maybe my question is somkind of challenge for someone who is borred at the moment ;D


well the Graph thing looks good i made somthing quick and dirty

use Graph::Easy::Parser; my $parser = Graph::Easy::Parser->new(); my $graph = $parser->from_text( '[ 0 ] -> [ 1 ]'. '[ 1 ] -> [ 202 ]'. '[ 1 ] -> [ 300 ]'. '[ 1 ] -> [ 344 ]'. '[ 2 ] -> [ 3 ]'. '[ 3 ] -> [ 4 ]'. '[ 4 ] -> [ 202 ]'. '[ 4 ] -> [ 345 ]'. '[ 4 ] -> [ 5 ]'. '[ 4 ] -> [ 6 ]'. '[ 5 ] -> [ 440 ]'. '[ 5 ] -> [ 500 ]'. '[ 5 ] -> [ 505 ]'. '[ 5 ] -> [ 508 ]'. '[ 5 ] -> [ 6 ]'. '[ 6 ] -> [ 201 ]'. '[ 6 ] -> [ 503 ]'. '[ 6 ] -> [ 507 ]'. '[ 6 ] -> [ 7 ]'. '[ 7 ] -> [ 2 ]'. '[ 7 ] -> [ 200 ]'. '[ 7 ] -> [ 503 ]'. '[ 7 ] -> [ 507 ]'. '[ 200 ] -> [ 202 ]'. '[ 202 ] -> [ 2 ]'. '[ 202 ] -> [ 201 ]'. '[ 300 ] -> [ 2 ]'. '[ 300 ] -> [ 202 ]'. '[ 300 ] -> [ 344 ]'. '[ 300 ] -> [ 502 ]'. '[ 300 ] -> [ 506 ]'. '[ 344 ] -> [ 300 ]'. '[ 345 ] -> [ 4 ]'. '[ 440 ] -> [ 5 ]'. '[ 500 ] -> [ 5 ]'. '[ 502 ] -> [ 300 ]'. '[ 503 ] -> [ 6 ]'. '[ 505 ] -> [ 5 ]'. '[ 506 ] -> [ 300 ]'. '[ 507 ] -> [ 6 ]'. '[ 508 ] -> [ 6 ]'. '[ 507 ] -> [ 7 ]'. '[ 503 ] -> [ 7 ]' ); print $graph->as_ascii();

now i just need to do it automaticly because a few things needs to be clear when you have more then one connection it depends on the order of notes if its going trough or not

for exp if you switch the last 2 lines in the code it will generate an compiler error, so i need to figure out how to do it manually , but im in bed now in 4 h i need to get to work

thx again for the hint
UPDATE i get that this is maybe to complex for this module because lots of connections are messed up and as an html file it spit out can only place 22 nodes out of 43 , but i will test tomorrow more

UPDATE 2so here is some more optimised version im atm writing som script that check all possible transitions and will link those who are same if the second pair is reversed as a double connection <-> and not as -> this save alot of lines in the tree, i find some eq testing for my second problem and will look this up but im not sure if i get it ;D

#!/usr/bin/perl use Graph::Easy::Parser; my $parser = Graph::Easy::Parser->new(); my $graph = $parser->from_text( "[ 0 ] -> [ 1 ]". "[ 1 ] -> [ 202 ]". "[ 1 ] -> [ 300 ]". "[ 1 ] -> [ 344 ]". "[ 300 ] <-> [ 344 ]". "[ 300 ] <-> [ 502 ]". "[ 300 ] <-> [ 506 ]". "[ 300 ] -> [ 2 ]". "[ 2 ] -> [ 3 ]". "[ 3 ] -> [ 4 ]". "[ 4 ] -> [ 5 ]". "[ 5 ] <-> [ 440 ]". "[ 5 ] <-> [ 500 ]". "[ 5 ] <-> [ 505 ]". "[ 5 ] -> [ 6 ]". "[ 5 ] -> [ 508 ]". "[ 508 ] -> [ 6 ]". "[ 6 ] <-> [ 503 ]". "[ 6 ] <-> [ 507 ]". "[ 6 ] -> [ 7 ]". "[ 7 ] <-> [ 503 ]". "[ 7 ] <-> [ 507 ]". "[ 7 ] -> [ 200 ]". "[ 200 ] -> [ 202 ]". "[ 202 ] -> [ 201 ]". "[ 6 ] -> [ 201 ]" ); print $graph->as_ascii();


Comment on Re^2: generating a Tree from Array and find the best way
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-08-30 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls