Algorithm for detecting longest cycle using nodes
#1

Okay, I am working on a minigame and I need some mathematical solutions. I'm not going to reveal whole load information about the minigame yet, but I've made some images with paint to illustrate what I'm after.

Lets assume playground would be 8-by-8 nodes. We have made some random pattern of green nodes. The node marked with 'F' is the one where we begin our cycle (could be any other).

* In first image, longest cycle is 12 nodes. It's also the shortest one.
* In second image, longest cycle is 6 nodes. Shortest is 4 nodes.

Well, I hope you can see how cycles are formed:

(1) (2)

As you can also see from the images, some paths may lead to dead end, so those paths have to be excluded somehow. I have yet to figure out how. How do you detect longest (or shortest) cycles here?

I have already made a script for detecting neighbor nodes. For ease of notation I use double array (x,y) to denote each node, is there any more efficient way? If you have solutions to meet my needs, please let me know
Reply


Messages In This Thread
Algorithm for detecting longest cycle using nodes - by Youarex - 27.06.2013, 16:38

Forum Jump:


Users browsing this thread: 2 Guest(s)