Files
C-Plus-Plus/d6/dd8/is__graph__bipartite_8cpp_source.html
2025-07-09 10:53:16 +00:00

244 lines
28 KiB
HTML

<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: graph/is_graph_bipartite.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('d6/dd8/is__graph__bipartite_8cpp_source.html','../../',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">is_graph_bipartite.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../d6/dd8/is__graph__bipartite_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#include &lt;queue&gt;</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a> {</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../de/d83/namespaceis__graph__bipartite.html">is_graph_bipartite</a> {</div>
<div class="foldopen" id="foldopen00051" data-start="{" data-end="};">
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html"> 51</a></span><span class="keyword">class </span><a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a6aef65b40347c4606662cad4dd2e14d3">Graph</a> {</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <span class="keyword">private</span>:</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef"> 53</a></span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">n</a>; </div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> </div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> std::vector&lt;std::vector&lt;int&gt; &gt;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f"> 56</a></span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">adj</a>; </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> </div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6"> 58</a></span> std::vector&lt;int&gt; <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>; </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> </div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keyword">public</span>:</div>
<div class="foldopen" id="foldopen00065" data-start="{" data-end="}">
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a6aef65b40347c4606662cad4dd2e14d3"> 65</a></span> <span class="keyword">explicit</span> <a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a6aef65b40347c4606662cad4dd2e14d3">Graph</a>(<span class="keywordtype">int</span> size) {</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">n</a> = size;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">adj</a>.resize(<a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">n</a>);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>.resize(<a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">n</a>, -1);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> }</div>
</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(<span class="keywordtype">int</span> u, <span class="keywordtype">int</span> v); </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordtype">bool</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca">is_bipartite</a>(); </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span>};</div>
</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span></div>
<div class="foldopen" id="foldopen00083" data-start="{" data-end="}">
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c"> 83</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">Graph::addEdge</a>(<span class="keywordtype">int</span> u, <span class="keywordtype">int</span> v) {</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">adj</a>[u - 1].push_back(v - 1);</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">adj</a>[v - 1].push_back(u - 1);</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span>}</div>
</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span></div>
<div class="foldopen" id="foldopen00106" data-start="{" data-end="}">
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca"> 106</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca">Graph::is_bipartite</a>() {</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="keywordtype">bool</span> check = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> std::queue&lt;int&gt; q;</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> current_edge = 0; current_edge &lt; <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">n</a>; ++current_edge) {</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[current_edge] == -1) {</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> q.push(current_edge);</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[current_edge] = 0;</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keywordflow">while</span> (q.size()) {</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordtype">int</span> current = q.front();</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> q.pop();</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> neighbour : <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">adj</a>[current]) {</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[neighbour] == -1) {</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[neighbour] = (1 ^ <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[current]);</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> q.push(neighbour);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> check &amp;= (<a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[neighbour] != <a class="code hl_variable" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">side</a>[current]);</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> }</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> }</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> }</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> }</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="keywordflow">return</span> check;</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span>}</div>
</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span>} <span class="comment">// namespace is_graph_bipartite</span></div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span>} <span class="comment">// namespace graph</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span></div>
<div class="foldopen" id="foldopen00136" data-start="{" data-end="}">
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"><a class="line" href="../../d6/dd8/is__graph__bipartite_8cpp.html#aa8dca7b867074164d5f45b0f3851269d"> 136</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../d6/dd8/is__graph__bipartite_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>() {</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> <a class="code hl_class" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html">graph::is_graph_bipartite::Graph</a> G1(</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> 5); </div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> G1.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(1, 2);</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> G1.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(1, 3);</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> G1.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(3, 4);</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> G1.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(4, 5);</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> </div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <a class="code hl_class" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html">graph::is_graph_bipartite::Graph</a> G2(</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> 3); </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> G2.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(1, 2);</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> G2.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(1, 3);</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> G2.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">addEdge</a>(2, 3);</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span></div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <span class="keywordflow">if</span> (G1.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca">is_bipartite</a>()) {</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> std::cout &lt;&lt; <span class="stringliteral">&quot;The given graph G1 is a bipartite graph\n&quot;</span>;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> std::cout &lt;&lt; <span class="stringliteral">&quot;The given graph G1 is not a bipartite graph\n&quot;</span>;</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> }</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <span class="keywordflow">if</span> (G2.<a class="code hl_function" href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca">is_bipartite</a>()) {</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> std::cout &lt;&lt; <span class="stringliteral">&quot;The given graph G2 is a bipartite graph\n&quot;</span>;</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> std::cout &lt;&lt; <span class="stringliteral">&quot;The given graph G2 is not a bipartite graph\n&quot;</span>;</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> }</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span>}</div>
</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span></div>
<div class="foldopen" id="foldopen00168" data-start="{" data-end="}">
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"><a class="line" href="../../d6/dd8/is__graph__bipartite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 168</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d6/dd8/is__graph__bipartite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <a class="code hl_function" href="../../d6/dd8/is__graph__bipartite_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); </div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span>}</div>
</div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html">graph::is_graph_bipartite::Graph</a></div><div class="ttdoc">Class for representing graph as an adjacency list.</div><div class="ttdef"><b>Definition</b> <a href="#l00051">is_graph_bipartite.cpp:51</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_a6aef65b40347c4606662cad4dd2e14d3"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a6aef65b40347c4606662cad4dd2e14d3">graph::is_graph_bipartite::Graph::Graph</a></div><div class="ttdeci">Graph(int size)</div><div class="ttdoc">Constructor that initializes the graph on creation.</div><div class="ttdef"><b>Definition</b> <a href="#l00065">is_graph_bipartite.cpp:65</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_a9b0c6400693a5cfff971f768dd5ca5ca"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9b0c6400693a5cfff971f768dd5ca5ca">graph::is_graph_bipartite::Graph::is_bipartite</a></div><div class="ttdeci">bool is_bipartite()</div><div class="ttdoc">function to add edges to our graph</div><div class="ttdef"><b>Definition</b> <a href="#l00106">is_graph_bipartite.cpp:106</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_a9d10768f927baa8a4d4a5ffce295b6b6"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#a9d10768f927baa8a4d4a5ffce295b6b6">graph::is_graph_bipartite::Graph::side</a></div><div class="ttdeci">std::vector&lt; int &gt; side</div><div class="ttdoc">stores the side of the vertex</div><div class="ttdef"><b>Definition</b> <a href="#l00058">is_graph_bipartite.cpp:58</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_ab0efcfa04fff8616aff0062522d1483f"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ab0efcfa04fff8616aff0062522d1483f">graph::is_graph_bipartite::Graph::adj</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; int &gt; &gt; adj</div><div class="ttdoc">adj stores the graph as an adjacency list</div><div class="ttdef"><b>Definition</b> <a href="#l00056">is_graph_bipartite.cpp:56</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_ad8c10df34357b2cd865c81e0c4f0bd8c"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#ad8c10df34357b2cd865c81e0c4f0bd8c">graph::is_graph_bipartite::Graph::addEdge</a></div><div class="ttdeci">void addEdge(int u, int v)</div><div class="ttdoc">Function that add an edge between two nodes or vertices of graph.</div><div class="ttdef"><b>Definition</b> <a href="#l00083">is_graph_bipartite.cpp:83</a></div></div>
<div class="ttc" id="aclassgraph_1_1is__graph__bipartite_1_1_graph_html_aefea7ee87a708298c486d5a38ac628ef"><div class="ttname"><a href="../../de/d00/classgraph_1_1is__graph__bipartite_1_1_graph.html#aefea7ee87a708298c486d5a38ac628ef">graph::is_graph_bipartite::Graph::n</a></div><div class="ttdeci">int n</div><div class="ttdoc">size of the graph</div><div class="ttdef"><b>Definition</b> <a href="#l00053">is_graph_bipartite.cpp:53</a></div></div>
<div class="ttc" id="ais__graph__bipartite_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d6/dd8/is__graph__bipartite_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdef"><b>Definition</b> <a href="#l00136">is_graph_bipartite.cpp:136</a></div></div>
<div class="ttc" id="ais__graph__bipartite_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../d6/dd8/is__graph__bipartite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition</b> <a href="#l00168">is_graph_bipartite.cpp:168</a></div></div>
<div class="ttc" id="anamespacegraph_html"><div class="ttname"><a href="../../df/dce/namespacegraph.html">graph</a></div><div class="ttdoc">Graph Algorithms.</div></div>
<div class="ttc" id="anamespaceis__graph__bipartite_html"><div class="ttname"><a href="../../de/d83/namespaceis__graph__bipartite.html">is_graph_bipartite</a></div><div class="ttdoc">Functions for checking whether a graph is bipartite or not.</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="../../dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li><li class="navelem"><a href="../../d6/dd8/is__graph__bipartite_8cpp.html">is_graph_bipartite.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
</ul>
</div>
</body>
</html>