0
votes

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

2 Answers

3
votes

If you can find a path from A-C and a path from C-D then you have your path A-C-D.

2
votes

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.