diff --git a/annotated.html b/annotated.html index 5c54b8e5a..485cf8b81 100644 --- a/annotated.html +++ b/annotated.html @@ -95,7 +95,7 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();
Here are the classes, structs, unions and interfaces with brief descriptions:
-
[detail level 12]
+
[detail level 123]
@@ -103,51 +103,54 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable(); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + +
 NciphersAlgorithms for encryption and decryption
 CHillCipherImplementation of Hill Cipher algorithm
 Ndata_structureData-structure algorithms
 CSkipList
 Ndouble_hashingAn implementation of hash table using double hashing algorithm
 CEntry
 Nlinear_probingAn implementation of hash table using linear probing algorithm
 CEntry
 Nmachine_learningMachine learning algorithms
 Cadaline
 Nquadratic_probingAn implementation of hash table using quadratic probing algorithm
 CEntry
 NstatisticsStatistical algorithms
 Cstats_computer1
 Cstats_computer2
 CBtree
 Ccll
 Ccompare
 CComplexClass Complex to represent complex numbers as a field
 CCycleCheck
 Cdouble_linked_list
 CEdge
 CFenwickTree
 CGraph
 Cgraph
 CGraph
 CLowestCommonAncestor
 CRootedTree
 Chash_chainChain class with a given modulus
 CItem
 Clarge_number
 Clinkedlist
 Clist
 CMinHeap
 CMinHeapNode
 Cmst
 Cnode
 NgraphGraph algorithms
 Nis_graph_bipartite
 CGraphClass for representing graph as an adjacency list
 Nlinear_probingAn implementation of hash table using linear probing algorithm
 CEntry
 Nmachine_learningMachine learning algorithms
 Cadaline
 Nquadratic_probingAn implementation of hash table using quadratic probing algorithm
 CEntry
 NstatisticsStatistical algorithms
 Cstats_computer1
 Cstats_computer2
 CBtree
 Ccll
 Ccompare
 CComplexClass Complex to represent complex numbers as a field
 CCycleCheck
 Cdouble_linked_list
 CEdge
 CFenwickTree
 CGraph
 Cgraph
 CGraph
 CLowestCommonAncestor
 CRootedTree
 Chash_chainChain class with a given modulus
 CItem
 Clarge_number
 Clinkedlist
 Clist
 CMinHeap
 CMinHeapNode
 Cmst
 CNode
 CPoint
 Cquery
 Cqueue
 CQueue
 CQueue_Array
 CSegmentIntersection
 CSolution
 Cstack
 Cstack_linkedList
 Ctower
 Ctrie
 Cnode
 CPoint
 Cquery
 Cqueue
 CQueue
 CQueue_Array
 CSegmentIntersection
 CSolution
 Cstack
 Cstack_linkedList
 Ctower
 CTrie
 CTrieNode
 Ctrie
diff --git a/annotated_dup.js b/annotated_dup.js index 2081c03f8..d2a1970c5 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -3,6 +3,7 @@ var annotated_dup = [ "ciphers", "d6/d4e/namespaceciphers.html", "d6/d4e/namespaceciphers" ], [ "data_structure", "d1/db4/namespacedata__structure.html", "d1/db4/namespacedata__structure" ], [ "double_hashing", "d0/d65/namespacedouble__hashing.html", "d0/d65/namespacedouble__hashing" ], + [ "graph", "df/dce/namespacegraph.html", "df/dce/namespacegraph" ], [ "linear_probing", "d8/d89/namespacelinear__probing.html", "d8/d89/namespacelinear__probing" ], [ "machine_learning", "d8/d77/namespacemachine__learning.html", "d8/d77/namespacemachine__learning" ], [ "quadratic_probing", "d4/dd2/namespacequadratic__probing.html", "d4/dd2/namespacequadratic__probing" ], @@ -25,8 +26,8 @@ var annotated_dup = [ "MinHeap", "d2/d05/class_min_heap.html", "d2/d05/class_min_heap" ], [ "MinHeapNode", "d5/d29/struct_min_heap_node.html", "d5/d29/struct_min_heap_node" ], [ "mst", "d1/d77/structmst.html", "d1/d77/structmst" ], - [ "node", "d5/da1/structnode.html", "d5/da1/structnode" ], [ "Node", "db/d8b/struct_node.html", "db/d8b/struct_node" ], + [ "node", "d5/da1/structnode.html", "d5/da1/structnode" ], [ "Point", "d8/dc8/struct_point.html", "d8/dc8/struct_point" ], [ "query", "dd/d1b/structquery.html", "dd/d1b/structquery" ], [ "queue", "db/da9/classqueue.html", "db/da9/classqueue" ], @@ -37,6 +38,6 @@ var annotated_dup = [ "stack", "d1/dc2/classstack.html", "d1/dc2/classstack" ], [ "stack_linkedList", "d2/dc4/classstack__linked_list.html", "d2/dc4/classstack__linked_list" ], [ "tower", "d2/d2c/structtower.html", "d2/d2c/structtower" ], - [ "trie", "d4/dd9/structtrie.html", "d4/dd9/structtrie" ], - [ "Trie", "dd/d2f/class_trie.html", "dd/d2f/class_trie" ] + [ "Trie", "dd/d2f/class_trie.html", "dd/d2f/class_trie" ], + [ "trie", "d4/dd9/structtrie.html", "d4/dd9/structtrie" ] ]; \ No newline at end of file diff --git a/classes.html b/classes.html index 9b7edf3b1..a24cced74 100644 --- a/classes.html +++ b/classes.html @@ -98,101 +98,102 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); }) - - - + + + + + + - - - - - - - + + + + - - - + - - + + - - - + + - + - - - + + - - - - + + + + - - - + + - - - + + + + + + + + + - + + + - + + - - - - - - - - - - - + + + + - - - +
  a  
Entry (linear_probing)   
  l  
-
  p  
+
Entry (quadratic_probing)   
  i  
Node (data_structure)   SkipList (data_structure)   
Entry (double_hashing)   node    Solution   
Entry (quadratic_probing)   stack   
adaline (machine_learning)   Entry (double_hashing)   large_number   Point   stack_linkedList   Entry (linear_probing)   Item   
  p  
+
stack   
  b  
  f  
linkedlist   
  q  
+
  l  
stats_computer1 (statistics)   stack_linkedList   
list   stats_computer2 (statistics)   
Point   stats_computer1 (statistics)   
Btree    FenwickTree   graph::LowestCommonAncestor   query   
  t  
+
large_number   
  q  
stats_computer2 (statistics)   
  c  
  g  
  m  
+
linkedlist   
  t  
queue   
Queue   tower   
list   query   
cll   Graph   MinHeap   Queue_Array   trie   graph::Graph   graph::LowestCommonAncestor   queue   tower   
compare   graph   MinHeapNode   
  r  
+
Graph   
  m  
Queue    Trie   
Complex   graph::Graph   mst   Trie::TrieNode   graph   Queue_Array   trie   
CycleCheck   Graph (graph::is_graph_bipartite)   MinHeap   
  r  
+
Trie::TrieNode   
  d  
+
  h  
  n  
-
MinHeapNode   
mst    graph::RootedTree   
  d  
+
double_linked_list   hash_chain   
  n  
  s  
hash_chain   Node (data_structure)   
double_linked_list   HillCipher (ciphers)   node   SegmentIntersection   
  e  
  i  
-
Node   SkipList (data_structure)   HillCipher (ciphers)   
Node   SegmentIntersection   
Edge   Item   
a | b | c | d | e | f | g | h | i | l | m | n | p | q | r | s | t
diff --git a/d0/d80/classgraph__coll__graph.map b/d0/d80/classgraph__coll__graph.map index 3a104610f..d410654d0 100644 --- a/d0/d80/classgraph__coll__graph.map +++ b/d0/d80/classgraph__coll__graph.map @@ -1,4 +1,5 @@ - - + + + diff --git a/d0/d80/classgraph__coll__graph.md5 b/d0/d80/classgraph__coll__graph.md5 index b58206570..752b58236 100644 --- a/d0/d80/classgraph__coll__graph.md5 +++ b/d0/d80/classgraph__coll__graph.md5 @@ -1 +1 @@ -8efd269804187eea2340c75ef8eaa740 \ No newline at end of file +f373125aa3f69b6483171ffe501254d6 \ No newline at end of file diff --git a/d0/d80/classgraph__coll__graph.svg b/d0/d80/classgraph__coll__graph.svg index 43d73dcf5..421e14607 100644 --- a/d0/d80/classgraph__coll__graph.svg +++ b/d0/d80/classgraph__coll__graph.svg @@ -4,11 +4,11 @@ - - + + graph - + Node1 @@ -35,5 +35,21 @@ adj + + +Node3 + + +std::vector< int > + + + + + +Node3->Node2 + + + elements + diff --git a/d4/d86/large__number_8h_source.html b/d4/d86/large__number_8h_source.html index f45db4ea7..bed19f3c4 100644 --- a/d4/d86/large__number_8h_source.html +++ b/d4/d86/large__number_8h_source.html @@ -405,6 +405,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
CycleCheck::isCyclicBFS
static bool isCyclicBFS(Graph const &graph)
Definition: cycle_check_directed_graph.cpp:249
std::strlen
T strlen(T... args)
quadratic_probing::removalInfo
void removalInfo(int key)
Definition: quadratic_probing_hash_table.cpp:222
+
graph::is_graph_bipartite::Graph::nax
static const int nax
stores the side of the vertex
Definition: is_graph_bipartite.cpp:57
Graph::getVertices
unsigned int getVertices() const
Definition: cycle_check_directed_graph.cpp:110
double_hashing::addInfo
void addInfo(int key)
Definition: double_hash_hash_table.cpp:212
double_hashing::otherHashFxn
size_t otherHashFxn(int key)
Used for second hash function.
Definition: double_hash_hash_table.cpp:58
@@ -412,6 +413,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::string
STL class.
std::equal
T equal(T... args)
std::shared_ptr
STL class.
+
is_graph_bipartite
Functions for checking whether a graph is bipartite or not.
graph::Graph::Graph
Graph(size_t N, const std::vector< std::pair< int, int > > &undirected_edges)
Populate the adjacency list for each vertex in the graph. Assumes that evey edge is a pair of valid v...
Definition: lowest_common_ancestor.cpp:61
MAX
#define MAX
Definition: fibonacci_fast.cpp:27
Graph::addVertices
void addVertices(unsigned int num=1)
Definition: cycle_check_directed_graph.cpp:118
@@ -482,6 +484,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
graph::explore
void explore(int, vector< bool > &)
Utility function for depth first seach algorithm this function explores the vertex which is passed in...
Definition: connected_components.cpp:101
std::search
T search(T... args)
quadratic_probing::putProber
bool putProber(const Entry &entry, int key)
Definition: quadratic_probing_hash_table.cpp:106
+
main
int main()
Definition: is_graph_bipartite.cpp:160
quadratic_probing::display
void display()
Definition: quadratic_probing_hash_table.cpp:142
quadratic_probing::Entry
Definition: quadratic_probing_hash_table.cpp:37
save_nd_data
int save_nd_data(const char *fname, const std::vector< std::valarray< double >> &X)
Definition: kohonen_som_trace.cpp:58
@@ -533,6 +536,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
MAX_ITER
constexpr int MAX_ITER
Definition: adaline_learning.cpp:40
spirograph
is_prime
bool is_prime(T num)
Definition: check_prime.cpp:22
+
test
static void test()
namespace graph
Definition: is_graph_bipartite.cpp:129
fast_power_recursive
double fast_power_recursive(T a, T b)
Definition: fast_power.cpp:26
std::tie
T tie(T... args)
Node
Definition: linkedlist_implentation_usingarray.cpp:14
@@ -578,6 +582,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::min_element
T min_element(T... args)
phiFunction
uint64_t phiFunction(uint64_t n)
Definition: eulers_totient_function.cpp:32
graph::Graph::neighbors
std::vector< std::vector< int > > neighbors
for each vertex it stores a list indicies of its neighbors
Definition: lowest_common_ancestor.cpp:78
+
graph::is_graph_bipartite::Graph::adj
std::vector< std::vector< int > > adj
size of the graph
Definition: is_graph_bipartite.cpp:53
double_hashing::hashFxn
size_t hashFxn(int key)
Hash a key. Uses the STL library's std::hash() function.
Definition: double_hash_hash_table.cpp:47
std::queue::pop
T pop(T... args)
std::stack::top
T top(T... args)
@@ -615,6 +620,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::invalid_argument
STL class.
test2
void test2()
Definition: kohonen_som_topology.cpp:451
SegmentIntersection::on_segment
bool on_segment(Point first_point, Point second_point, Point third_point)
Definition: line_segment_intersection.cpp:75
+
graph::is_graph_bipartite::Graph::is_bipartite
bool is_bipartite()
function to add edges to our graph
Definition: is_graph_bipartite.cpp:98
operator==
bool operator==(const Complex &a, const Complex &b)
Operator overload of '==' on Complex class. Logical Equal overload for our Complex class.
Definition: complex_numbers.cpp:175
double_hashing::rehash
void rehash()
Definition: double_hash_hash_table.cpp:161
large_number::_digits
std::vector< unsigned char > _digits
Definition: large_number.h:285
@@ -635,6 +641,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
Graph::Graph
Graph(unsigned int vertices, AdjList &&adjList)
Definition: cycle_check_directed_graph.cpp:76
std::priority_queue
STL class.
std::rand
T rand(T... args)
+
graph::is_graph_bipartite::Graph::side
std::vector< int > side
adj stores the graph as an adjacency list
Definition: is_graph_bipartite.cpp:55
save_2d_data
int save_2d_data(const char *fname, const std::vector< std::valarray< double >> &X)
Definition: kohonen_som_topology.cpp:65
linear_probing
An implementation of hash table using linear probing algorithm.
test_lamniscate
void test_lamniscate(std::vector< std::valarray< double >> *data)
Definition: kohonen_som_trace.cpp:277
@@ -686,6 +693,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
graph::Graph::number_of_vertices
int number_of_vertices() const
Definition: lowest_common_ancestor.cpp:73
compare
Definition: huffman.cpp:28
std::ios_base::sync_with_stdio
T sync_with_stdio(T... args)
+
graph::is_graph_bipartite::Graph::Graph
Graph(int size=nax)
Constructor that initializes the graph on creation.
Definition: is_graph_bipartite.cpp:64
stack
Definition: stack.h:26
tests
static void tests()
Definition: lowest_common_ancestor.cpp:234
get_clock_diff
double get_clock_diff(clock_t start_t, clock_t end_t)
Definition: kohonen_som_topology.cpp:577
@@ -738,6 +746,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::range_error
STL class.
Point
Definition: line_segment_intersection.cpp:12
large_number::operator!=
friend bool operator!=(large_number const &a, large_number const &b)
Definition: large_number.h:168
+
graph::is_graph_bipartite::Graph
Class for representing graph as an adjacency list.
Definition: is_graph_bipartite.cpp:49
machine_learning::kohonen_som
void kohonen_som(const std::vector< std::valarray< double >> &X, std::vector< std::vector< std::valarray< double >>> *W, double alpha_min)
Definition: kohonen_som_topology.cpp:269
push
void push(char ch)
push byte to stack variable
Definition: paranthesis_matching.cpp:26
Trie::removeWordHelper
std::shared_ptr< TrieNode > removeWordHelper(const std::string &word, std::shared_ptr< TrieNode > curr, size_t index)
Definition: trie_modern.cpp:64
@@ -771,6 +780,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
machine_learning::kohonen_som_tracer
void kohonen_som_tracer(const std::vector< std::valarray< double >> &X, std::vector< std::valarray< double >> *W, double alpha_min)
Definition: kohonen_som_trace.cpp:149
graph::connected_components
int connected_components
keep track of connected components
Definition: connected_components.cpp:43
are_amicable
bool are_amicable(int x, int y)
Definition: check_amicable_pair.cpp:48
+
graph::is_graph_bipartite::Graph::addEdge
void addEdge(int u, int v)
Function that add an edge between two nodes or vertices of graph.
Definition: is_graph_bipartite.cpp:81
std::exit
T exit(T... args)
stack::clear
void clear()
Definition: stack.h:112
main
int main(int argc, char **argv)
Definition: adaline_learning.cpp:357
diff --git a/d6/dd8/is__graph__bipartite_8cpp.html b/d6/dd8/is__graph__bipartite_8cpp.html new file mode 100644 index 000000000..8dd19d191 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp.html @@ -0,0 +1,260 @@ + + + + + + + +Algorithms_in_C++: graph/is_graph_bipartite.cpp File Reference + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ +  1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
is_graph_bipartite.cpp File Reference
+
+
+ +

Algorithm to check whether a graph is bipartite +More...

+
#include <iostream>
+#include <vector>
+#include <queue>
+
+Include dependency graph for is_graph_bipartite.cpp:
+
+
+
+
+
+ + + + +

+Classes

class  graph::is_graph_bipartite::Graph
 Class for representing graph as an adjacency list. More...
 
+ + + + + + + +

+Namespaces

 graph
 Graph algorithms.
 
 is_graph_bipartite
 Functions for checking whether a graph is bipartite or not.
 
+ + + + + + +

+Functions

static void test ()
 namespace graph More...
 
int main ()
 
+

Detailed Description

+

Algorithm to check whether a graph is bipartite

+

A graph is a collection of nodes also called vertices and these vertices are connected by edges.A bipartite graph is a graph whose vertices can be divided into two disjoint and independent sets U and V such that every edge connects a vertex in U to one in V.
+

+

The given Algorithm will determine whether the given graph is bipartite or not

+
+Example - Here is a graph g1 with 5 vertices and is bipartite
    1   4
+   / \ / \
+  2   3   5
Example - Here is a graph G2 with 3 vertices and is not bipartite
    1 --- 2
+     \   /
+       3
Author
Akshat Vaya
+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + +
int main ()
+
+

Main function

+

Testing

+
160  {
+
161  test(); ///Testing
+
162  return 0;
+
163 }
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + +
static void test ()
+
+static
+
+ +

namespace graph

+

Function to test the above algorithm

Returns
none
+

creating graph G1 with 5 vertices

+

adding edges to the graphs as per the illustrated example

+

creating graph G2 with 3 vertices

+

adding edges to the graphs as per the illustrated example

+

checking whether the graphs are bipartite or not

+
129  {
+
130  graph::is_graph_bipartite::Graph G1(5); /// creating graph G1 with 5 vertices
+
131  /// adding edges to the graphs as per the illustrated example
+
132  G1.addEdge(1,2);
+
133  G1.addEdge(1,3);
+
134  G1.addEdge(3,4);
+
135  G1.addEdge(4,5);
+
136 
+
137  graph::is_graph_bipartite::Graph G2(3); /// creating graph G2 with 3 vertices
+
138  /// adding edges to the graphs as per the illustrated example
+
139  G2.addEdge(1,2);
+
140  G2.addEdge(1,3);
+
141  G2.addEdge(2,3);
+
142 
+
143  /// checking whether the graphs are bipartite or not
+
144  if(G1.is_bipartite()){
+
145  std::cout<<"The given graph G1 is a bipartite graph\n";
+
146  }
+
147  else{
+
148  std::cout<<"The given graph G1 is not a bipartite graph\n";
+
149  }
+
150  if(G2.is_bipartite()){
+
151  std::cout<<"The given graph G2 is a bipartite graph\n";
+
152  }
+
153  else{
+
154  std::cout<<"The given graph G2 is not a bipartite graph\n";
+
155  }
+
156 }
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+
+
+
test
static void test()
namespace graph
Definition: is_graph_bipartite.cpp:129
+
std::cout
+
graph::is_graph_bipartite::Graph
Class for representing graph as an adjacency list.
Definition: is_graph_bipartite.cpp:49
+ + + + diff --git a/d6/dd8/is__graph__bipartite_8cpp.js b/d6/dd8/is__graph__bipartite_8cpp.js new file mode 100644 index 000000000..fdcd1a293 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp.js @@ -0,0 +1,6 @@ +var is__graph__bipartite_8cpp = +[ + [ "Graph", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph" ], + [ "main", "d6/dd8/is__graph__bipartite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "test", "d6/dd8/is__graph__bipartite_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..43c53d499 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,6 @@ + + + + + + diff --git a/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..22d9b4c77 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +a6549d119662d6201a83efd94768f2b3 \ No newline at end of file diff --git a/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..12d3466f0 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,69 @@ + + + + + + +test + + + +Node1 + + +test + + + + + +Node2 + + +graph::is_graph_bipartite +::Graph::addEdge + + + + + +Node1->Node2 + + + + + +Node4 + + +graph::is_graph_bipartite +::Graph::is_bipartite + + + + + +Node1->Node4 + + + + + +Node3 + + +std::vector::push_back + + + + + +Node2->Node3 + + + + + diff --git a/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..9fe4bf654 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..7df3c19c0 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +4304c99872312673eb221911fd941f45 \ No newline at end of file diff --git a/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..674f61829 --- /dev/null +++ b/d6/dd8/is__graph__bipartite_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,84 @@ + + + + + + +main + + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + +Node3 + + +graph::is_graph_bipartite +::Graph::addEdge + + + + + +Node2->Node3 + + + + + +Node5 + + +graph::is_graph_bipartite +::Graph::is_bipartite + + + + + +Node2->Node5 + + + + + +Node4 + + +std::vector::push_back + + + + + +Node3->Node4 + + + + + diff --git a/da/d50/is__graph__bipartite_8cpp__incl.map b/da/d50/is__graph__bipartite_8cpp__incl.map new file mode 100644 index 000000000..4c8d96ae0 --- /dev/null +++ b/da/d50/is__graph__bipartite_8cpp__incl.map @@ -0,0 +1,6 @@ + + + + + + diff --git a/da/d50/is__graph__bipartite_8cpp__incl.md5 b/da/d50/is__graph__bipartite_8cpp__incl.md5 new file mode 100644 index 000000000..19b13a422 --- /dev/null +++ b/da/d50/is__graph__bipartite_8cpp__incl.md5 @@ -0,0 +1 @@ +c0030b115283fa45bde1216ac7ceaa23 \ No newline at end of file diff --git a/da/d50/is__graph__bipartite_8cpp__incl.svg b/da/d50/is__graph__bipartite_8cpp__incl.svg new file mode 100644 index 000000000..580c2cd82 --- /dev/null +++ b/da/d50/is__graph__bipartite_8cpp__incl.svg @@ -0,0 +1,67 @@ + + + + + + +graph/is_graph_bipartite.cpp + + + +Node1 + + +graph/is_graph_bipartite.cpp + + + + + +Node2 + + +iostream + + + + + +Node1->Node2 + + + + + +Node3 + + +vector + + + + + +Node1->Node3 + + + + + +Node4 + + +queue + + + + + +Node1->Node4 + + + + + diff --git a/dc/d67/classgraph_1_1is__graph__bipartite_1_1_graph-members.html b/dc/d67/classgraph_1_1is__graph__bipartite_1_1_graph-members.html new file mode 100644 index 000000000..b690b4d5c --- /dev/null +++ b/dc/d67/classgraph_1_1is__graph__bipartite_1_1_graph-members.html @@ -0,0 +1,118 @@ + + + + + + + +Algorithms_in_C++: Member List + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ +  1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
graph::is_graph_bipartite::Graph Member List
+
+
+ +

This is the complete list of members for graph::is_graph_bipartite::Graph, including all inherited members.

+ + + + + + + + +
addEdge(int u, int v)graph::is_graph_bipartite::Graph
adjgraph::is_graph_bipartite::Graphprivate
Graph(int size=nax)graph::is_graph_bipartite::Graphinlineexplicit
is_bipartite()graph::is_graph_bipartite::Graph
n (defined in graph::is_graph_bipartite::Graph)graph::is_graph_bipartite::Graphprivate
naxgraph::is_graph_bipartite::Graphprivatestatic
sidegraph::is_graph_bipartite::Graphprivate
+
+ + + + diff --git a/dd/d9b/classgraph.html b/dd/d9b/classgraph.html index fb5971db3..c7f358df9 100644 --- a/dd/d9b/classgraph.html +++ b/dd/d9b/classgraph.html @@ -103,7 +103,7 @@ $(document).ready(function(){initNavTree('dd/d9b/classgraph.html','../../'); ini
Collaboration diagram for graph:
-
+
[legend]
diff --git a/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html new file mode 100644 index 000000000..94eca501b --- /dev/null +++ b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html @@ -0,0 +1,261 @@ + + + + + + + +Algorithms_in_C++: graph::is_graph_bipartite::Graph Class Reference + + + + + + + + + + + + + + + +
+
+
+ + + + + +
+
Algorithms_in_C++ +  1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
graph::is_graph_bipartite::Graph Class Reference
+
+
+ +

Class for representing graph as an adjacency list. + More...

+
+Collaboration diagram for graph::is_graph_bipartite::Graph:
+
+
+
+
[legend]
+ + + + + + + + + + + +

+Public Member Functions

Graph (int size=nax)
 Constructor that initializes the graph on creation.
 
void addEdge (int u, int v)
 Function that add an edge between two nodes or vertices of graph. More...
 
bool is_bipartite ()
 function to add edges to our graph More...
 
+ + + + + + + + + +

+Private Attributes

+int n
 
+std::vector< std::vector< int > > adj
 size of the graph
 
+std::vector< int > side
 adj stores the graph as an adjacency list
 
+ + + + +

+Static Private Attributes

+static const int nax = 5e5 + 1
 stores the side of the vertex
 
+

Detailed Description

+

Class for representing graph as an adjacency list.

+

Member Function Documentation

+ +

◆ addEdge()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void Graph::addEdge (int u,
int v 
)
+
+ +

Function that add an edge between two nodes or vertices of graph.

+
Parameters
+ + + +
uis a node or vertex of graph
vis a node or vertex of graph
+
+
+
81  {
+
82  adj[u-1].push_back(v-1);
+
83  adj[v-1].push_back(u-1);
+
84  }
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ is_bipartite()

+ +
+
+ + + + + + + +
bool Graph::is_bipartite ()
+
+ +

function to add edges to our graph

+

function that checks whether the graph is bipartite or not the function returns true if the graph is a bipartite graph the function returns false if the graph is not a bipartite graph

+

Here, side refers to the two disjoint subsets of the bipartite graph. Initially, the values of side are set to -1 which is an unassigned state. A for loop is run for every vertex of the graph. If the current edge has no side assigned to it, then a Breadth First Search operation is performed. If two neighbours have the same side then the graph will not be bipartite and the value of check becomes false. If and only if each pair of neighbours have different sides, the value of check will be true and hence the graph bipartite.

+
98  {
+
99  bool check = true;
+
100  std::queue<int> q;
+
101  for (int current_edge = 0; current_edge < n; ++current_edge)
+
102  {
+
103  if(side[current_edge] == -1){
+
104  q.push(current_edge);
+
105  side[current_edge] = 0;
+
106  while(q.size()){
+
107  int current = q.front();
+
108  q.pop();
+
109  for(auto neighbour : adj[current]){
+
110  if(side[neighbour] == -1){
+
111  side[neighbour] = (1 ^ side[current]);
+
112  q.push(neighbour);
+
113  }
+
114  else{
+
115  check &= (side[neighbour] != side[current]);
+
116  }
+
117  }
+
118  }
+
119  }
+
120  }
+
121  return check;
+
122  }
+
+
+
+
The documentation for this class was generated from the following file: +
+
+
std::queue
STL class.
+
std::vector::push_back
T push_back(T... args)
+
graph::is_graph_bipartite::Graph::adj
std::vector< std::vector< int > > adj
size of the graph
Definition: is_graph_bipartite.cpp:53
+
graph::is_graph_bipartite::Graph::side
std::vector< int > side
adj stores the graph as an adjacency list
Definition: is_graph_bipartite.cpp:55
+ + + + diff --git a/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.js b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.js new file mode 100644 index 000000000..4854db60e --- /dev/null +++ b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.js @@ -0,0 +1,10 @@ +var classgraph_1_1is__graph__bipartite_1_1_graph = +[ + [ "Graph", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a477bf401cab737bb313f687b08fff082", null ], + [ "addEdge", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c", null ], + [ "is_bipartite", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca", null ], + [ "adj", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a70dea3a7ae9738067e6b84abc192e429", null ], + [ "n", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef", null ], + [ "nax", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a275227d01fbecdcf2f890b034fcea655", null ], + [ "side", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6", null ] +]; \ No newline at end of file diff --git a/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.map b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.map new file mode 100644 index 000000000..7ac35694e --- /dev/null +++ b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.md5 b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.md5 new file mode 100644 index 000000000..43c59c05f --- /dev/null +++ b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.md5 @@ -0,0 +1 @@ +1d4c77e8b001dd4fa41ca0c561614ebc \ No newline at end of file diff --git a/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.svg b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.svg new file mode 100644 index 000000000..4ca9d607f --- /dev/null +++ b/de/d00/classgraph_1_1is__graph__bipartite_1_1_graph_ad8c10df34357b2cd865c81e0c4f0bd8c_cgraph.svg @@ -0,0 +1,38 @@ + + + + + + +graph::is_graph_bipartite::Graph::addEdge + + + +Node1 + + +graph::is_graph_bipartite +::Graph::addEdge + + + + + +Node2 + + +std::vector::push_back + + + + + +Node1->Node2 + + + + + diff --git a/de/d83/namespaceis__graph__bipartite.html b/de/d83/namespaceis__graph__bipartite.html new file mode 100644 index 000000000..9a8209469 --- /dev/null +++ b/de/d83/namespaceis__graph__bipartite.html @@ -0,0 +1,114 @@ + + + + + + + +Algorithms_in_C++: is_graph_bipartite Namespace Reference + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ +  1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
is_graph_bipartite Namespace Reference
+
+
+ +

Functions for checking whether a graph is bipartite or not. +More...

+

Detailed Description

+

Functions for checking whether a graph is bipartite or not.

+
+
+ + + + diff --git a/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.map b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.map new file mode 100644 index 000000000..51420dea9 --- /dev/null +++ b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.md5 b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.md5 new file mode 100644 index 000000000..02019c2b9 --- /dev/null +++ b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.md5 @@ -0,0 +1 @@ +c729d60a5f149f6ec52ab9a17f49379d \ No newline at end of file diff --git a/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.svg b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.svg new file mode 100644 index 000000000..4baaa2f87 --- /dev/null +++ b/df/db7/classgraph_1_1is__graph__bipartite_1_1_graph__coll__graph.svg @@ -0,0 +1,56 @@ + + + + + + +graph::is_graph_bipartite::Graph + + + +Node1 + + +graph::is_graph_bipartite +::Graph + + + + + +Node2 + + +std::vector< std::vector +< int > > + + + + + +Node2->Node1 + + + adj + + + +Node3 + + +std::vector< int > + + + + + +Node3->Node1 + + + side + + + diff --git a/df/dce/namespacegraph.js b/df/dce/namespacegraph.js new file mode 100644 index 000000000..eb0126637 --- /dev/null +++ b/df/dce/namespacegraph.js @@ -0,0 +1,6 @@ +var namespacegraph = +[ + [ "is_graph_bipartite", null, [ + [ "Graph", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html", "de/d00/classgraph_1_1is__graph__bipartite_1_1_graph" ] + ] ] +]; \ No newline at end of file diff --git a/dir_12552d7fa429bf94a2e32e5cf39f7e69.html b/dir_12552d7fa429bf94a2e32e5cf39f7e69.html index 04799665b..a1d2ce695 100644 --- a/dir_12552d7fa429bf94a2e32e5cf39f7e69.html +++ b/dir_12552d7fa429bf94a2e32e5cf39f7e69.html @@ -106,6 +106,9 @@ Files file  hamiltons_cycle.cpp  The implementation of Hamilton's cycle dynamic solution for vertices number less than 20.
  +file  is_graph_bipartite.cpp + Algorithm to check whether a graph is bipartite
+  file  lowest_common_ancestor.cpp  Data structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting.
  diff --git a/dir_12552d7fa429bf94a2e32e5cf39f7e69.js b/dir_12552d7fa429bf94a2e32e5cf39f7e69.js index 0158cc9d9..4a7fc7521 100644 --- a/dir_12552d7fa429bf94a2e32e5cf39f7e69.js +++ b/dir_12552d7fa429bf94a2e32e5cf39f7e69.js @@ -3,5 +3,6 @@ var dir_12552d7fa429bf94a2e32e5cf39f7e69 = [ "breadth_first_search.cpp", "df/d82/breadth__first__search_8cpp.html", "df/d82/breadth__first__search_8cpp" ], [ "connected_components.cpp", "df/ddd/connected__components_8cpp.html", "df/ddd/connected__components_8cpp" ], [ "hamiltons_cycle.cpp", "dd/d0c/hamiltons__cycle_8cpp.html", "dd/d0c/hamiltons__cycle_8cpp" ], + [ "is_graph_bipartite.cpp", "d6/dd8/is__graph__bipartite_8cpp.html", "d6/dd8/is__graph__bipartite_8cpp" ], [ "lowest_common_ancestor.cpp", "de/dde/lowest__common__ancestor_8cpp.html", "de/dde/lowest__common__ancestor_8cpp" ] ]; \ No newline at end of file diff --git a/files.html b/files.html index 8816313ab..d126020d4 100644 --- a/files.html +++ b/files.html @@ -127,7 +127,8 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });  breadth_first_search.cppBreadth First Search Algorithm (Breadth First Search)  connected_components.cppGraph Connected Components (Connected Components)  hamiltons_cycle.cppThe implementation of Hamilton's cycle dynamic solution for vertices number less than 20 - lowest_common_ancestor.cppData structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting + is_graph_bipartite.cppAlgorithm to check whether a graph is bipartite + lowest_common_ancestor.cppData structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting   graphics  spirograph.cppImplementation of Spirograph   hashing diff --git a/functions.html b/functions.html index d997c52e9..8a52664e3 100644 --- a/functions.html +++ b/functions.html @@ -122,14 +122,16 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable(); : large_number
  • addEdge() -: Graph +: Graph , graph +, graph::is_graph_bipartite::Graph
  • addVertices() : Graph
  • adj : graph +, graph::is_graph_bipartite::Graph
  • arg() : Complex @@ -280,13 +282,14 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable(); : Graph
  • Graph() -: Graph +: Graph
  • graph() : graph
  • Graph() : graph::Graph +, graph::is_graph_bipartite::Graph
  • @@ -329,6 +332,9 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
  • insertKey() : MinHeap
  • +
  • is_bipartite() +: graph::is_graph_bipartite::Graph +
  • isCyclicBFS() : CycleCheck
  • @@ -399,6 +405,9 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();

    - n -

    @@ -285,6 +287,9 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl
  • insertKey() : MinHeap
  • +
  • is_bipartite() +: graph::is_graph_bipartite::Graph +
  • isCyclicBFS() : CycleCheck
  • diff --git a/functions_vars.html b/functions_vars.html index 6274fd279..73c3f55d6 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -108,6 +108,7 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl
  • adj : graph +, graph::is_graph_bipartite::Graph
  • @@ -179,6 +180,9 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl

    - n -