arrays - How to get all possible paths through a graph of knots easily in php -
i want calculate costs each possible path through network (geographical). therefore need every possible combination of knots in network.
we have simple case: knots 1-4 fixed startpoint @ 1 , condition every knot has part of path -> length every path equal
1->2->3->4 1->2->4->3 1->3->2->4 1->3->4->2 1->4->2->3 1->4->3->2
my preferred result should be:
<?php $array = array( array(1,2,3,4), array(1,2,4,3), array(1,3,2,4), array(1,3,4,2), array(1,4,2,3), array(1,4,3,2) ) ?>
can tell me how calculate possible paths through network given number of knots , fixed start?
thanks in advance!
Comments
Post a Comment