fix: clang-format for graph/ (#1056)

* fix: clang-format for graph/

* remove graph.h
This commit is contained in:
Filip Hlasek
2020-08-27 07:28:31 -07:00
committed by GitHub
parent 3239fcc19e
commit 79fb528dad
11 changed files with 67 additions and 60 deletions

View File

@@ -3,9 +3,8 @@
*/
#include <iostream>
#include <vector>
#include <stack>
#include <vector>
/**
* Iterative function/method to print graph:
@@ -13,7 +12,7 @@
* @param V number of vertices
* @return void
**/
void print(const std::vector< std::vector<int> > &a, int V) {
void print(const std::vector<std::vector<int> > &a, int V) {
for (int i = 0; i < V; i++) {
if (!a[i].empty()) {
std::cout << "i=" << i << "-->";
@@ -35,7 +34,8 @@ void print(const std::vector< std::vector<int> > &a, int V) {
* @param adj adjacency list representation of the graph
* @return void
**/
void push_vertex(int v, std::stack<int> *st, std::vector<bool> *vis, const std::vector< std::vector<int> > &adj) {
void push_vertex(int v, std::stack<int> *st, std::vector<bool> *vis,
const std::vector<std::vector<int> > &adj) {
(*vis)[v] = true;
for (auto i = adj[v].begin(); i != adj[v].end(); i++) {
if ((*vis)[*i] == false) {
@@ -52,7 +52,8 @@ void push_vertex(int v, std::stack<int> *st, std::vector<bool> *vis, const std::
* @param grev graph with reversed edges
* @return void
**/
void dfs(int v, std::vector<bool> *vis, const std::vector< std::vector<int> > &grev) {
void dfs(int v, std::vector<bool> *vis,
const std::vector<std::vector<int> > &grev) {
(*vis)[v] = true;
// cout<<v<<" ";
for (auto i = grev[v].begin(); i != grev[v].end(); i++) {
@@ -72,7 +73,7 @@ no SCCs i.e. none(0) or there will be x no. of SCCs (x>0)) i.e. it returns the
count of (number of) strongly connected components (SCCs) in the graph.
(variable 'count_scc' within function)
**/
int kosaraju(int V, const std::vector< std::vector<int> > &adj) {
int kosaraju(int V, const std::vector<std::vector<int> > &adj) {
std::vector<bool> vis(V, false);
std::stack<int> st;
for (int v = 0; v < V; v++) {
@@ -81,7 +82,7 @@ int kosaraju(int V, const std::vector< std::vector<int> > &adj) {
}
}
// making new graph (grev) with reverse edges as in adj[]:
std::vector< std::vector<int> > grev(V);
std::vector<std::vector<int> > grev(V);
for (int i = 0; i < V + 1; i++) {
for (auto j = adj[i].begin(); j != adj[i].end(); j++) {
grev[*j].push_back(i);
@@ -114,7 +115,7 @@ int main() {
int a = 0, b = 0; // a->number of nodes, b->directed edges.
std::cin >> a >> b;
int m = 0, n = 0;
std::vector< std::vector<int> > adj(a + 1);
std::vector<std::vector<int> > adj(a + 1);
for (int i = 0; i < b; i++) // take total b inputs of 2 vertices each
// required to form an edge.
{