I implemented a depth-first-search in c# based on information I found on the net and old java books and I used the Node and NodeList and Graph from the msdn site. How can one modify the DFS or BFS to check for particular weight?
+2
A:
To implement a DFS, you need to use a stack implicit (recursively call the function itself) or explicit (use a stack object). For each state, you have a current node you are visiting. You will have to visited each neighbor of the current node, and also if you have visited the current node, then you can skip processing the current one.
That is pretty much the algorithm. What you need to do is translating that to code.
leiz
2009-09-10 05:37:07
I already have that.., I just need to check if path exisits
2009-09-10 05:50:38
the path exists as long as you reach to that node from a starting node
leiz
2009-09-10 07:35:19
@leiz - well, yes and no, let's say path exisits from A to D, but you want to see if there's a path from A to D via C (e.g. A-C-D).
2009-09-10 16:54:04
+3
A:
If you can find a path from A-C and a path from C-D then you have your path A-C-D.
Carles
2009-09-10 17:03:31