A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/da/d8d/depth__first__search_8cpp_source.html below:

TheAlgorithms/C++: graph/depth_first_search.cpp Source File

Go to the documentation of this file. 56void addEdge

(std::vector<std::vector<size_t>> *adj,

size_t

u,

size_t

v) {

64

(*adj)[u - 1].push_back(v - 1);

65

(*adj)[v - 1].push_back(u - 1);

80void explore

(

const

std::vector<std::vector<size_t>> &adj,

size_t

v,

81

std::vector<bool> *visited) {

82

std::cout << v + 1 <<

" "

;

83

(*visited)[v] =

true

;

84 for

(

auto

x : adj[v]) {

101 size_t

vertices = adj.size();

103

std::vector<bool> visited(vertices,

false

);

104 explore

(adj, start, &visited);

110 size_t

vertices = 0, edges = 0;

111

std::cout <<

"Enter the Vertices : "

;

112

std::cin >> vertices;

113

std::cout <<

"Enter the Edges : "

;

117

std::vector<std::vector<size_t>> adj(vertices, std::vector<size_t>());

120

std::cout <<

"Enter the vertices which have edges between them : " 129

graph::depth_first_search(adj, 2);

131

std::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