graph visit

I can't implement graph visit (BFS and DFS) of my graph, I'm stopped for many days..
please help me.
I have graph with this class:

1
2
3
4
5
6
7
8
9
10
11
  class myClass{
public:
   myClass();
   ~myClass();
   myClass* getLeft(){return left);
   myClass* getRight(){return Right);
protected:
private: 
   myClass* left;
   myClass* right;
};


How to do it? I saw lots of example, but I don't understand very well how to do them..
For example, It's better for me to add attributes "visited", "longestPath", "shortestPath" to myClass?
I know that I always ask for the same things, but I have to get graduated and I'm quite desperated.. nobody could help me.
Please, help me on this problem
Hello ema897,

You first need to ask a question the smart way http://www.catb.org/esr/faqs/smart-questions.html#before

Just saying:
I can't implement graph visit (BFS and DFS) of my graph
.
Is "graph visit " a function that you did not show or something else?

BFS and DFS may mean something to you, but I am not sure what this is referring to.

When you talk about attributes of "visited", "longestPath", "shortestPath" this makes me think that you are working with a tree.

Your class looks OK for now although if you have nothing to follow "protected:" there is no reason to have it there unless you have a future use for it. Also with out seeing the function definitions for the default ctor and dtor I would have to question if you need them in the class.

Most times it is best to include all the code that can be compiled and run. This way anyone that reads this can see what you are doing. And sometimes the problem is not in what you first show, but elsewhere when you try to use it or in how you use it.

Andy
I have to implement different visits.
I don't if the graph is actually a graph or a binary tree.
If there are loops it will be a graph.
I have to implement visits for:
-check feedback (i think i need bfs)
-find shortest path
-find longest path
-find leaves
-longest loop
-shortest loop
Topic archived. No new replies allowed.