Skip to content

Instantly share code, notes, and snippets.

@Luoyayu
Luoyayu / print_all_simple_path.cpp
Last active January 3, 2018 05:39
print_all_simple_path
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
vector<int> ans, g[maxn];
bool vis[maxn];
void dfs(vector<int>p, int cur, int t) {
p.push_back(cur);
vis[cur] = 1;
if (cur == t) {
for (auto x:p) printf("%d ", x);
@Luoyayu
Luoyayu / find_cycle_in_graph.cpp
Last active January 18, 2018 09:11
find_all_cycle_in_graph_dfs
// 输出图中的所有的环
//color label :white(not visited),black(all children have been visited),gray(start visiting node)
// if one edge direct to a gray node means has cycle.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+3;
vector<int>g[maxn];
int vis[maxn];//0 while,1 gray, 2 black
int fa[maxn];