Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global list

Status
Not open for further replies.

Zuulde

Programmer
Oct 10, 2010
5
DK
Hi Guys!

I am in a need of help! Sorry if my English is not okay.
So let's see my problem:
I would like to make a pathing algorith on direcred nodes.
so 1 -> 2, 1 -> 3, 2 -> 1 means 1 can visit 2 and 3, and 2 can visit 1, but 3 cannot visit 1.
I would like to visit all nodes from a given node. My function header looks like this: traversal(G, X) g = graph, X = node.
I would like to use a global "list", where I can remove elements, that I have already visited so far: In the starting situation all elements exists in the G. After 1 visits 2, I would like to remove 1 from the list (and 2 also).
Of course in some situation there can be a "dead end", and prolog will backtrack.
The problem is, prolog will "go back in time" with list: It will use the list before the dead and happend. I want to not let this happen. If 3 -> 4 happens, Remove 3 from G (and also 4). If 4 is a dead and, I don't want 3 and 4 to be again on the list.
I hope I am clear.
 
Oh I didn't mention, but a dead-end is considered as a fail.
So that's why BackTrack will happen.
Only success happens only, when my G is empty: all nodes have been visited.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top