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();

In reply to Re^2: generating a Tree from Array and find the best way by ultibuzz
in thread generating a Tree from Array and find the best way by ultibuzz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.