Please accept my sincere gratitude for being a wonderful Perl resource for everyone!
With great humility and respect, I put forth this question before you:
I am developing a new graph algorithm that utilizes the Graph module. The Graph module provides the $g->vertices() method. The results this method returns in a list context, are not deterministic. That is, for the same graph, when you call:
my @vertices = $g->vertices();the vertices might be in different order. Since I rely on this method, my algorithm is also not deterministic. For a fixed given input, my algorithm produces the correct result, but the number of times it recurses varies wildly.
I could just change it to:
my @vertices = sort $g->vertices();everywhere, but that would kill the performance of the algorithm. Is there a better way?
Also, I would appreciate any tips on computing the Big-O complexity of an algorithm implemented in Perl. Does one have to mentally unfurl every line of Perl down to C, while computing the complexity?
I await your wise and erudite responses to enlighten me.
In reply to Algorithm Complexity and Determinism of Graph Module by ownlifeful
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |