An array of hashes, each hash containing one path, its ID, and its order ( foreward (F) or reverse (R) )

each path is initialized in the F position

my @paths = [ { id => 1, path => [A,B], order => 'F' }, { id => 2, pat +h => [C,D,E], order => 'F' }, { id => 3, path => [E,B], order => 'F' +} ];

each node or vertex of each path also has an orientation ( + or - )

my %plus_minus; $plus_minus{1}{A} = '+'; $plus_minus{1}{B} = '+'; $plus_minus{2}{C} = '+'; $plus_minus{2}{D} = '-'; $plus_minus{2}{E} = '-'; $plus_minus{3}{E} = '-'; $plus_minus{3}{B} = '-';

You can reverse the order of a path ( e.g., A, B to B, A )

When you reverse order from F => R or R => F you also switch the orientation of each node in the path from + to - or - to +

The paths with orientations look like this:

1 .A+ : B+

2. C+ : D- : E-

3. E- : B-

this is the problem input for output, i'd like to know whether or not it is possible by reverseing path orders to create a consensus path and also what is the way to do this such that you are guaranteed to find the consensus path

for example, if we reversed path 1 we'd get:

1. B- : A-

2. C+ : D- : E-

3. E- : B-

and the resulting consensus path would be:

C+ : D- : E- : B- : A-

but it's not clear to reverse path 1 first; for example; what if started by reversing path 3? So you can't proceed randomly. Does anyone recognize this problem? Does it have a solution? Thanks.


In reply to Formalizing an array type problem, looking for solution by melmoth

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.