melmoth has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|