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/d83/kosaraju_8cpp_source.html below:

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

15void

print(

const

std::vector<std::vector<int> > &a,

int

V) {

16 for

(

int

i = 0; i < V; i++) {

18

std::cout <<

"i="

<< i <<

"-->"

;

21

std::cout << j <<

" "

;

24

std::cout << std::endl;

37void

push_vertex(

int

v, std::stack<int> *st, std::vector<bool> *vis,

38 const

std::vector<std::vector<int> > &adj) {

40 for

(

auto

i = adj[v].begin(); i != adj[v].end(); i++) {

41 if

((*vis)[*i] ==

false

) {

42

push_vertex(*i, st, vis, adj);

55void

dfs(

int

v, std::vector<bool> *vis,

56 const

std::vector<std::vector<int> > &grev) {

59 for

(

auto

i = grev[v].begin(); i != grev[v].end(); i++) {

60 if

((*vis)[*i] ==

false

) {

76int

kosaraju(

int

V,

const

std::vector<std::vector<int> > &adj) {

77

std::vector<bool> vis(V,

false

);

79 for

(

int

v = 0; v < V; v++) {

80 if

(vis[v] ==

false

) {

81

push_vertex(v, &st, &vis, adj);

85

std::vector<std::vector<int> > grev(V);

86 for

(

int

i = 0; i < V + 1; i++) {

87 for

(

auto

j = adj[i].begin(); j != adj[i].end(); j++) {

88

grev[*j].push_back(i);

94 for

(

int

i = 0; i < V; i++) vis[i] =

false

;

99 if

(vis[t] ==

false

) {

118

std::vector<std::vector<int> > adj(a + 1);

119 for

(

int

i = 0; i < b; i++)

126

std::cout << kosaraju(a, adj) << std::endl;

int main()

Main function.


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