Hello,
I have a question:
Algorithm DFS(Vertex V)
mark[V] := 1;
print[V];
for each (edge (V, W)) do
if mark[W] = 0;
DFS(W);
I would like to realize this recursive procedure (depth-first search), but in my graph representation (with adjacency lists) I use two different classes, one for the vertex, one for the edge, like this:
class Edge;
class Vertex
{
public:
Vertex* vNext;
char Element;
bool marked;
Edge* adjList;
// Contructor...
};
class Edge
{
public:
Edge* eNext;
char Element;
bool marked;
int weight;
// Contructor...
};
So I cannot use the procedure with two different parameters (Vertex and Edge), or is there any way to preserve the recursion with different parameter types?
Thank you for your help!