# competitive-programming-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kmyk/competitive-programming-library

# graph/transpose_graph.hpp

## Depends on

• utils/macros.hpp

## Code

#pragma once
#include <vector>
#include "utils/macros.hpp"

/**
* @param g is an adjacent list of a digraph
* @note $O(V + E)$
* @see https://en.wikipedia.org/wiki/Transpose_graph
*/
std::vector<std::vector<int> > make_transpose_graph(std::vector<std::vector<int> > const & g) {
int n = g.size();
std::vector<std::vector<int> > h(n);
REP (i, n) {
for (int j : g[i]) {
h[j].push_back(i);
}
}
return h;
}



#line 2 "graph/transpose_graph.hpp"
#include <vector>
#line 2 "utils/macros.hpp"
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
#line 4 "graph/transpose_graph.hpp"

/**
* @param g is an adjacent list of a digraph
* @note $O(V + E)$
* @see https://en.wikipedia.org/wiki/Transpose_graph
*/
std::vector<std::vector<int> > make_transpose_graph(std::vector<std::vector<int> > const & g) {
int n = g.size();
std::vector<std::vector<int> > h(n);
REP (i, n) {
for (int j : g[i]) {
h[j].push_back(i);
}
}
return h;
}