Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


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

======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:
Eve,BigDaddy,Father John,Eve,Son John,Chang,Son Chang,Eve,Mother
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_1

While 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_5

The 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1095149]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-23 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found