Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Optimization Help

by BrowserUk (Pope)
on Aug 01, 2013 at 23:57 UTC ( #1047519=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Optimization Help
in thread Optimization Help

Try:

sub equate2 { my ($self, $other, $mapping) = @_; my $sm = $self->{Matrix}; my $om = $other->{Matrix}; for my $row ( 0 .. $#$mapping ) { my $smrow = $sm->[ $row ]; my $omrow = $om->[ $mapping->[ $row ] ]; for my $col ( 0 .. $#$mapping ) { return 0 if $smrow->[ $col ] != $omrow->[ $mapping->[ $col + ] ]; } } return 1; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: Optimization Help
Download Code
Re^4: Optimization Help
by jmmitc06 (Acolyte) on Aug 02, 2013 at 05:07 UTC
    I am in your debt!!!!! In my test case this is 40% faster, that's going to save me a couple of days right there.

      How big is $mapping? (And can you show us (some of) what it contains? Eg. the mapping sequence.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Mapping is of total length equal to $#{$self->Matrix}, and represents the mapping of a node in graph 1 to the node in graph 2. So the first element in $mapping indicates that the first node in the graph1 is mapped to said node in graph 2, with -1 indicating no match. Most of the time, the size of $mapping is in the 20 to 150 element range, although there are outliers.

        Below is an example of how mapping changes when comparing two identical graphs:

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,- +1 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 0,1,-1,-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16,17,-1,-1,-1,-1,-1,-1 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,-1,-1,-1,-1,-1 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,-1,-1,-1,-1 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,-1,-1,-1 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,-1,-1 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,-1

        And here with dissimilar graphs:

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1 0,-1,-1,-1,-1,-1,-1,-1,-1,-1 0,-1,-1,-1,-1,-1,-1,-1,-1,-1 1,-1,-1,-1,-1,-1,-1,-1,-1,-1 1,-1,-1,-1,-1,-1,-1,-1,-1,-1 3,-1,-1,-1,-1,-1,-1,-1,-1,-1 3,-1,-1,-1,-1,-1,-1,-1,-1,-1 4,-1,-1,-1,-1,-1,-1,-1,-1,-1 4,-1,-1,-1,-1,-1,-1,-1,-1,-1 6,-1,-1,-1,-1,-1,-1,-1,-1,-1 6,-1,-1,-1,-1,-1,-1,-1,-1,-1 8,-1,-1,-1,-1,-1,-1,-1,-1,-1 8,-1,-1,-1,-1,-1,-1,-1,-1,-1

      BrowserUK has a well-earned reputation for doing things like that ...   :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-07-30 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls