diff --git a/dd/d9b/classgraph.js b/dd/d9b/classgraph.js
index 7c1a2899e..37de31def 100644
--- a/dd/d9b/classgraph.js
+++ b/dd/d9b/classgraph.js
@@ -1,16 +1,10 @@
var classgraph =
[
- [ "graph", "dd/d9b/classgraph.html#a01de7229e455294187882cf48c5865f1", null ],
[ "graph", "dd/d9b/classgraph.html#a6da44f9820d3b7bae2f0f74bc149c27e", null ],
- [ "addedge", "dd/d9b/classgraph.html#a0d1f72b044a0ff541da4672481625fe5", null ],
[ "addEdge", "dd/d9b/classgraph.html#a35c12fba596d8bb48b1877b128c4ba6d", null ],
- [ "bfs", "dd/d9b/classgraph.html#a907cab58d8b38ab3798ad4d043670914", null ],
[ "depth_first_search", "dd/d9b/classgraph.html#a135921a59082b669678b029b301b8a1c", null ],
[ "explore", "dd/d9b/classgraph.html#a6398e513b9574e029fbee07c6ac6e028", null ],
[ "getConnectedComponents", "dd/d9b/classgraph.html#af9b34bbae0f618e2128c501b69339bb0", null ],
- [ "printgraph", "dd/d9b/classgraph.html#a12c78a42f38c3b46637cf0da488824e9", null ],
- [ "adj", "dd/d9b/classgraph.html#abf45919942312aee0679dcd56e8aae9a", null ],
[ "adj", "dd/d9b/classgraph.html#a45045da3d080cb81472ce6d5cc02b911", null ],
- [ "connected_components", "dd/d9b/classgraph.html#a822dcbe7978a9fa026f2b37f1a52f5e9", null ],
- [ "v", "dd/d9b/classgraph.html#af77d6c400ef60f882b8beca48db8017d", null ]
+ [ "connected_components", "dd/d9b/classgraph.html#a822dcbe7978a9fa026f2b37f1a52f5e9", null ]
];
\ No newline at end of file
diff --git a/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.map b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.map
new file mode 100644
index 000000000..c4f67b820
--- /dev/null
+++ b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.map
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.md5 b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.md5
new file mode 100644
index 000000000..46aef618e
--- /dev/null
+++ b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.md5
@@ -0,0 +1 @@
+de7620d1ab0c421b9577b2a5d1548f27
\ No newline at end of file
diff --git a/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.svg b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.svg
new file mode 100644
index 000000000..0d23faf52
--- /dev/null
+++ b/dd/d9b/classgraph_a35c12fba596d8bb48b1877b128c4ba6d_cgraph.svg
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+graph::addEdge
+
+
+
+Node1
+
+
+graph::addEdge
+
+
+
+
+
+Node2
+
+
+std::vector::push_back
+
+
+
+
+
+Node1->Node2
+
+
+
+
+
diff --git a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.map b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.map
index 4133016c9..bbc0eacae 100644
--- a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.map
+++ b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.map
@@ -1,5 +1,6 @@
-
-
-
+
+
+
+
diff --git a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.md5 b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.md5
index 8a79faa5a..2906aeaeb 100644
--- a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.md5
+++ b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.md5
@@ -1 +1 @@
-8e668cb1a81ccc2dd2b38cc34d5905ae
\ No newline at end of file
+18338ec11bf113da8a29226a8b02f060
\ No newline at end of file
diff --git a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.svg b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.svg
index ed9904842..d318ac5fe 100644
--- a/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.svg
+++ b/dd/d9b/classgraph_af9b34bbae0f618e2128c501b69339bb0_cgraph.svg
@@ -4,17 +4,17 @@
-
-
+
+
graph::getConnectedComponents
-
+
Node1
-
-graph::getConnectedComponents
+
+graph::getConnectedComponents
@@ -22,32 +22,47 @@
Node2
-
-graph::depth_first
-_search
+
+graph::depth_first
+_search
Node1->Node2
-
-
+
+
Node3
-
-graph::explore
+
+graph::explore
Node2->Node3
-
-
+
+
+
+
+
+Node4
+
+
+std::vector::size
+
+
+
+
+
+Node2->Node4
+
+
diff --git a/df/d82/breadth__first__search_8cpp.html b/df/d82/breadth__first__search_8cpp.html
new file mode 100644
index 000000000..6552292e9
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp.html
@@ -0,0 +1,297 @@
+
+
+
+
+
+
+
+Algorithms_in_C++: graph/breadth_first_search.cpp File Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Algorithms_in_C++
+ 1.0.0
+
+ Set of algorithms implemented in C++.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Breadth First Search Algorithm (Breadth First Search)
+More...
+
#include <algorithm>
+#include <cassert>
+#include <iostream>
+#include <queue>
+#include <vector>
+
+
+
Breadth First Search Algorithm (Breadth First Search)
+
Author Ayaan Khan
+
Breadth First Search also quoted as BFS is a Graph Traversal Algorithm. Time Complexity O(|V| + |E|) where V are the number of vertices and E are the number of edges in the graph.
+
Applications of Breadth First Search are
+
+Finding shortest path between two vertices say u and v, with path length measured by number of edges (an advantage over depth first search algorithm)
+Ford-Fulkerson Method for computing the maximum flow in a flow network.
+Testing bipartiteness of a graph.
+Cheney's Algorithm, Copying garbage collection.
+
+
And there are many more...
+
working
+
In the implementation below we first created a graph using the adjacency list representation of graph. Breadth First Search Works as follows it requires a vertex as a start vertex, Start vertex is that vertex from where you want to start traversing the graph. We maintain a bool array or a vector to keep track of the vertices which we have visited so that we do not traverse the visited vertices again and again and eventually fall into an infinite loop. Along with this boolen array we use a Queue .
+
+First we mark the start vertex as visited.
+Push this visited vertex in the Queue .
+while the queue is not empty we repeat the following steps
+Take out an element from the front of queue
+Explore the adjacency list of this vertex if element in the adjacency list is not visited then we push that element into the queue and mark this as visited
+
+
+
+
+
+
◆ main()
+
+
+
+
+
+ int main
+ (
+ )
+
+
+
+
+
Main function
+
+
+
+
164 size_t vertices = 0, edges = 0;
+
165 std::cout <<
"Enter the number of vertices: " ;
+
+
167 std::cout <<
"Enter the number of edges: " ;
+
+
+
+
+
172 std::cout <<
"Enter space-separated pairs of vertices that form edges: "
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
◆ tests()
+
+
+
+
+
+ void tests
+ (
+ )
+
+
+
+
+
Test 1 Begin
+
Test 2 Begin
+
Test 3 Begins
+
+
+
+
+
+
+
+
+
+
+
+
132 returned_result.
begin ()));
+
+
+
+
+
+
+
139 returned_result.
begin ()));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
153 correct_result = {
false ,
false ,
true ,
true ,
false ,
true };
+
+
+
156 returned_result.
begin ()));
+
+
+
+
+
+
+
+
+
+std::vector< bool > breadth_first_search(const std::vector< std::vector< int >> &graph, int start)
Function performs the breadth first search algorithm over the graph.
Definition: breadth_first_search.cpp:95
+
+
+void add_directed_edge(std::vector< std::vector< int >> *graph, int u, int v)
Adds a directed edge from vertex u to vertex v.
Definition: breadth_first_search.cpp:66
+
+void add_undirected_edge(std::vector< std::vector< int >> *graph, int u, int v)
Adds an undirected edge from vertex u to vertex v. Essentially adds too directed edges to the adjacen...
Definition: breadth_first_search.cpp:81
+void tests()
Definition: breadth_first_search.cpp:121
+
+
+
+
+
+
+
+
+
diff --git a/df/d82/breadth__first__search_8cpp.js b/df/d82/breadth__first__search_8cpp.js
new file mode 100644
index 000000000..b72018b82
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp.js
@@ -0,0 +1,8 @@
+var breadth__first__search_8cpp =
+[
+ [ "add_directed_edge", "df/d82/breadth__first__search_8cpp.html#adbe6cd1fd148173ce6a01669925d2d72", null ],
+ [ "add_undirected_edge", "df/d82/breadth__first__search_8cpp.html#a59b4441a0e447469e9a4f61c87f33102", null ],
+ [ "breadth_first_search", "df/d82/breadth__first__search_8cpp.html#a618dce14b4883c20aace1d743d3a3f60", null ],
+ [ "main", "df/d82/breadth__first__search_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ],
+ [ "tests", "df/d82/breadth__first__search_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9", null ]
+];
\ No newline at end of file
diff --git a/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.map b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.map
new file mode 100644
index 000000000..854774135
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.map
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.md5 b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.md5
new file mode 100644
index 000000000..0c217f24b
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.md5
@@ -0,0 +1 @@
+5e5f4f943e9ea8c27c86fa24828587b7
\ No newline at end of file
diff --git a/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg
new file mode 100644
index 000000000..e7b1191c0
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg
@@ -0,0 +1,194 @@
+
+
+
+
+
+
+tests
+
+
+
+Node1
+
+
+tests
+
+
+
+
+
+Node2
+
+
+graph::add_directed_edge
+
+
+
+
+
+Node1->Node2
+
+
+
+
+
+Node3
+
+
+graph::add_undirected_edge
+
+
+
+
+
+Node1->Node3
+
+
+
+
+
+Node4
+
+
+std::vector::begin
+
+
+
+
+
+Node1->Node4
+
+
+
+
+
+Node5
+
+
+graph::breadth_first
+_search
+
+
+
+
+
+Node1->Node5
+
+
+
+
+
+Node10
+
+
+std::vector::end
+
+
+
+
+
+Node1->Node10
+
+
+
+
+
+Node11
+
+
+std::endl
+
+
+
+
+
+Node1->Node11
+
+
+
+
+
+Node12
+
+
+std::equal
+
+
+
+
+
+Node1->Node12
+
+
+
+
+
+Node3->Node2
+
+
+
+
+
+Node6
+
+
+std::queue::empty
+
+
+
+
+
+Node5->Node6
+
+
+
+
+
+Node7
+
+
+std::queue::front
+
+
+
+
+
+Node5->Node7
+
+
+
+
+
+Node8
+
+
+std::queue::pop
+
+
+
+
+
+Node5->Node8
+
+
+
+
+
+Node9
+
+
+std::queue::push
+
+
+
+
+
+Node5->Node9
+
+
+
+
+
diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map
new file mode 100644
index 000000000..8c2d9260d
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5
new file mode 100644
index 000000000..7d44b6f2d
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5
@@ -0,0 +1 @@
+40dd88972af9386c3538eebfa94fd7ef
\ No newline at end of file
diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg
new file mode 100644
index 000000000..373277dec
--- /dev/null
+++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+main
+
+
+
+Node1
+
+
+main
+
+
+
+
+
+Node2
+
+
+graph::add_directed_edge
+
+
+
+
+
+Node1->Node2
+
+
+
+
+
+Node3
+
+
+graph::breadth_first
+_search
+
+
+
+
+
+Node1->Node3
+
+
+
+
+
+Node8
+
+
+std::endl
+
+
+
+
+
+Node1->Node8
+
+
+
+
+
+Node9
+
+
+tests
+
+
+
+
+
+Node1->Node9
+
+
+
+
+
+Node4
+
+
+std::queue::empty
+
+
+
+
+
+Node3->Node4
+
+
+
+
+
+Node5
+
+
+std::queue::front
+
+
+
+
+
+Node3->Node5
+
+
+
+
+
+Node6
+
+
+std::queue::pop
+
+
+
+
+
+Node3->Node6
+
+
+
+
+
+Node7
+
+
+std::queue::push
+
+
+
+
+
+Node3->Node7
+
+
+
+
+
+Node9->Node2
+
+
+
+
+
+Node9->Node3
+
+
+
+
+
+Node9->Node8
+
+
+
+
+
+Node10
+
+
+graph::add_undirected_edge
+
+
+
+
+
+Node9->Node10
+
+
+
+
+
+Node11
+
+
+std::vector::begin
+
+
+
+
+
+Node9->Node11
+
+
+
+
+
+Node12
+
+
+std::vector::end
+
+
+
+
+
+Node9->Node12
+
+
+
+
+
+Node13
+
+
+std::equal
+
+
+
+
+
+Node9->Node13
+
+
+
+
+
+Node10->Node2
+
+
+
+
+
diff --git a/df/dce/namespacegraph.html b/df/dce/namespacegraph.html
new file mode 100644
index 000000000..33108873c
--- /dev/null
+++ b/df/dce/namespacegraph.html
@@ -0,0 +1,310 @@
+
+
+
+
+
+
+
+Algorithms_in_C++: graph Namespace Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Algorithms_in_C++
+ 1.0.0
+
+ Set of algorithms implemented in C++.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Graph algorithms.
+More...
+
+
+
+
+
◆ add_directed_edge()
+
+
+
+
+
+ void graph::add_directed_edge
+ (
+ std::vector < std::vector < int >> *
+ graph ,
+
+
+
+
+ int
+ u ,
+
+
+
+
+ int
+ v
+
+
+
+ )
+
+
+
+
+
+
Adds a directed edge from vertex u to vertex v.
+
Parameters
+
+ graph Adjacency list representation of graph
+ u first vertex
+ v second vertex
+
+
+
+
+
67 (*graph)[u].push_back(v);
+
+
+
+
+
+
◆ add_undirected_edge()
+
+
+
+
+
+ void graph::add_undirected_edge
+ (
+ std::vector < std::vector < int >> *
+ graph ,
+
+
+
+
+ int
+ u ,
+
+
+
+
+ int
+ v
+
+
+
+ )
+
+
+
+
+
+
Adds an undirected edge from vertex u to vertex v. Essentially adds too directed edges to the adjacency list reprsentation of the graph.
+
Parameters
+
+ graph Adjacency list representation of graph
+ u first vertex
+ v second vertex
+
+
+
+
+
+
+
+
+
+
◆ breadth_first_search()
+
+
+
+
+
Function performs the breadth first search algorithm over the graph.
+
Parameters
+
+ graph Adjacency list representation of graph
+ start vertex from where traversing starts
+
+
+
+
Returns a binary vector indicating which vertices were visited during the search.
+
vector to keep track of visited vertices
+
a queue that stores vertices that need to be further explored
+
mark the starting vertex as visited
+
if the vertex is not visited then mark it as visited and push it to the queue
+
+
+
+
+
+
+
+
103 visited[start] =
true ;
+
+
105 while (!tracker.
empty ()) {
+
106 size_t vertex = tracker.
front ();
+
+
108 for (
auto x :
graph [vertex]) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void add_directed_edge(std::vector< std::vector< int >> *graph, int u, int v)
Adds a directed edge from vertex u to vertex v.
Definition: breadth_first_search.cpp:66
+
+
+
+
+
+
+
+
+
+
diff --git a/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.map b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.map
new file mode 100644
index 000000000..a2d9acf91
--- /dev/null
+++ b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.map
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.md5 b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.md5
new file mode 100644
index 000000000..268ccd599
--- /dev/null
+++ b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.md5
@@ -0,0 +1 @@
+f83673a87e6ad89177d27be6b462b17f
\ No newline at end of file
diff --git a/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.svg b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.svg
new file mode 100644
index 000000000..e04cf4d11
--- /dev/null
+++ b/df/dce/namespacegraph_a59b4441a0e447469e9a4f61c87f33102_cgraph.svg
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+graph::add_undirected_edge
+
+
+
+Node1
+
+
+graph::add_undirected_edge
+
+
+
+
+
+Node2
+
+
+graph::add_directed_edge
+
+
+
+
+
+Node1->Node2
+
+
+
+
+
diff --git a/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.map b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.map
new file mode 100644
index 000000000..dee66e8d0
--- /dev/null
+++ b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.map
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.md5 b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.md5
new file mode 100644
index 000000000..864ef61a7
--- /dev/null
+++ b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.md5
@@ -0,0 +1 @@
+8d35e2a7e3be3a76448f79b4d4b3c8e5
\ No newline at end of file
diff --git a/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.svg b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.svg
new file mode 100644
index 000000000..df69501b8
--- /dev/null
+++ b/df/dce/namespacegraph_a618dce14b4883c20aace1d743d3a3f60_cgraph.svg
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+graph::breadth_first_search
+
+
+
+Node1
+
+
+graph::breadth_first
+_search
+
+
+
+
+
+Node2
+
+
+std::queue::empty
+
+
+
+
+
+Node1->Node2
+
+
+
+
+
+Node3
+
+
+std::queue::front
+
+
+
+
+
+Node1->Node3
+
+
+
+
+
+Node4
+
+
+std::queue::pop
+
+
+
+
+
+Node1->Node4
+
+
+
+
+
+Node5
+
+
+std::queue::push
+
+
+
+
+
+Node1->Node5
+
+
+
+
+
diff --git a/df/ddd/connected__components_8cpp.html b/df/ddd/connected__components_8cpp.html
index bb1564da2..971d72e0e 100644
--- a/df/ddd/connected__components_8cpp.html
+++ b/df/ddd/connected__components_8cpp.html
@@ -150,7 +150,7 @@ Example - Here is graph with 3 connected components 3 9
printing the connected components
-
+
@@ -163,7 +163,7 @@ Example - Here is graph with 3 connected components
3 9
-
@@ -171,8 +171,8 @@ Here is the call graph for this function:
-