in reply to Re: Perl code for finding shortest path not working on large files (chomp)
in thread Perl code for finding shortest path not working on large files
Im sorry for the delay but here it is, and hope Im clear enough.
Consider the input file:So in this case consider the first column,we have 3 children : Eve, John, Chang.Eve,BigDaddy,Father John,Eve,Son John,Chang,Son Chang,Eve,Mother
The third column is the relation of second column to first column.
For each of them we need to find their shortest link to the BigDaddy(or "Q" as I have shown in the sample input file. "Q" is the BigDaddy in the sample input case. So for Eve we already have the shortest path to BigDaddy which is
Eve : Eve<-BigDaddy, Father , Male_relations_1While for John, John is related to eve as (Son) and Eve is BigDaddy as (Father). Thus the third column will have their relationships concatenated :
John: John<-Eve<-BigDaddy, Son.Father , Male_relations_5The fourth column is the Relation id for these concatenated relations. These sets of relation ids will already be given (as you can see in the code its inside the hash %DEF). Eg
DEF = ( Male_relations => [qw(Father Father.Son Son Brother Son.Father +.....)], Female_relations => [qw(Mother Mother.Son Aunt Aunt.Father ....)])
The concatenated relation between John and BigDaddy is Son.Father, which is number 5 in the Male_relations, hence we denote Male_relations_5
|
|---|