Just another Perl shrine | |
PerlMonks |
Re^2: Perl code for finding shortest path not working on large files (chomp)by zing (Beadle) |
on Jul 26, 2014 at 07:54 UTC ( [id://1095149]=note: print w/replies, xml ) | Need Help?? |
======The much needed explanation of the code====
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. 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
The concatenated relation between John and BigDaddy is Son.Father, which is number 5 in the Male_relations, hence we denote Male_relations_5
In Section
Seekers of Perl Wisdom
|
|