Professional Documents
Culture Documents
Graph Program
Graph Program
Graph Program
h>
#define MAX 10
class DFS
{
private : int n;
int adj[MAX][MAX];
int visited[MAX];
public : void dfs(int);
void readmatrix();
};
int main()
{
int source;
DFS depth;
depth.readmatrix();
cout << "\nEnter the Source : ";
cin >> source;
cout << "\nThe nodes visited in the DFS order is : ";
depth.dfs(source);
return 0;
}
• Program output