(std::vector<std::vector<size_t>> *adj,
size_tu,
size_tv) {
64(*adj)[u - 1].push_back(v - 1);
65(*adj)[v - 1].push_back(u - 1);
80void explore(
conststd::vector<std::vector<size_t>> &adj,
size_tv,
81std::vector<bool> *visited) {
82std::cout << v + 1 <<
" ";
83(*visited)[v] =
true;
84 for(
autox : adj[v]) {
101 size_tvertices = adj.size();
103std::vector<bool> visited(vertices,
false);
104 explore(adj, start, &visited);
110 size_tvertices = 0, edges = 0;
111std::cout <<
"Enter the Vertices : ";
112std::cin >> vertices;
113std::cout <<
"Enter the Edges : ";
117std::vector<std::vector<size_t>> adj(vertices, std::vector<size_t>());
120std::cout <<
"Enter the vertices which have edges between them : " 129graph::depth_first_search(adj, 2);
131std::cout << std::endl;
Functions for Depth First Search algorithm.
void explore(const std::vector< std::vector< int > > *adj, int u, std::vector< bool > *visited)
Utility function for depth first seach algorithm this function explores the vertex which is passed in...
void addEdge(std::vector< std::vector< int > > *adj, int u, int v)
Function that add edge between two nodes or vertices of graph.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4