struct Edge { int src, dest; }; class Graph { public: vector<vector<int>> adjList; Graph(vector<Edge> const &edges, int n) { adjList.resize(n); for (auto &edge : edges) { adjList[edge.src].push_back(edge.dest); adjList[edge.dest].push_back(edge.src); } } }; void DFS(Graph const &graph, int v, vector<bool> &discovered) { discovered[v] = true; cout << v << " "; for (int u : graph.adjList[v]) { if (!discovered[u]) { DFS(graph, u, discovered); } } }
Inscription number 91,262
Genesis block 776,556
File type text
File size 510 b
Creation date