Files
C-Plus-Plus/d0/d58/classgraph_1_1_rooted_tree.html
2024-08-30 17:22:07 +00:00

301 lines
28 KiB
HTML

<!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.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: graph::RootedTree Class Reference</title>
<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="../../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="../../resize.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/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.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="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</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">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('d0/d58/classgraph_1_1_rooted_tree.html','../../'); initResizable(true); });
/* @license-end */
</script>
<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="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="../../d5/d55/classgraph_1_1_rooted_tree-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">graph::RootedTree Class Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="dynheader">
Inheritance diagram for graph::RootedTree:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d9b/classgraph_1_1_rooted_tree__inherit__graph.svg" width="140" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<center><span class="legend">[<a target="top" href="../../graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for graph::RootedTree:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/d24/classgraph_1_1_rooted_tree__coll__graph.svg" width="379" height="348"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<center><span class="legend">[<a target="top" href="../../graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aacdeecac857623e9fbfe92590f3c504d" id="r_aacdeecac857623e9fbfe92590f3c504d"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aacdeecac857623e9fbfe92590f3c504d">RootedTree</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; int, int &gt; &gt; &amp;undirected_edges, int root_)</td></tr>
<tr class="memdesc:aacdeecac857623e9fbfe92590f3c504d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs the tree by calculating parent for every vertex. Assumes a valid description of a tree is provided. <br /></td></tr>
<tr class="separator:aacdeecac857623e9fbfe92590f3c504d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classgraph_1_1_graph"><td colspan="2" onclick="javascript:dynsection.toggleInherit('pub_methods_classgraph_1_1_graph')"><img src="../../closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="../../dc/d61/classgraph_1_1_graph.html">graph::Graph&lt; T &gt;</a></td></tr>
<tr class="memitem:a877b2cba40d8d46dde6fb4209effed19 inherit pub_methods_classgraph_1_1_graph" id="r_a877b2cba40d8d46dde6fb4209effed19"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d61/classgraph_1_1_graph.html#a877b2cba40d8d46dde6fb4209effed19">add_edge</a> (T u, T v, bool bidir=true)</td></tr>
<tr class="separator:a877b2cba40d8d46dde6fb4209effed19 inherit pub_methods_classgraph_1_1_graph"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3755ec9e6a842238c7f4aac10b661981 inherit pub_methods_classgraph_1_1_graph" id="r_a3755ec9e6a842238c7f4aac10b661981"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map.html">std::map</a>&lt; T, bool &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d61/classgraph_1_1_graph.html#a3755ec9e6a842238c7f4aac10b661981">breadth_first_search</a> (T src)</td></tr>
<tr class="separator:a3755ec9e6a842238c7f4aac10b661981 inherit pub_methods_classgraph_1_1_graph"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8839fa14bff19d2deab4a618447c13e5 inherit pub_methods_classgraph_1_1_graph" id="r_a8839fa14bff19d2deab4a618447c13e5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d61/classgraph_1_1_graph.html#a8839fa14bff19d2deab4a618447c13e5">Graph</a> (size_t N, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; int, int &gt; &gt; &amp;undirected_edges)</td></tr>
<tr class="memdesc:a8839fa14bff19d2deab4a618447c13e5 inherit pub_methods_classgraph_1_1_graph"><td class="mdescLeft">&#160;</td><td class="mdescRight">Populate the adjacency list for each vertex in the graph. Assumes that evey edge is a pair of valid vertex indices. <br /></td></tr>
<tr class="separator:a8839fa14bff19d2deab4a618447c13e5 inherit pub_methods_classgraph_1_1_graph"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8930d1470d132b19e430d1c71f94c904 inherit pub_methods_classgraph_1_1_graph" id="r_a8930d1470d132b19e430d1c71f94c904"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d61/classgraph_1_1_graph.html#a8930d1470d132b19e430d1c71f94c904">number_of_vertices</a> () const</td></tr>
<tr class="separator:a8930d1470d132b19e430d1c71f94c904 inherit pub_methods_classgraph_1_1_graph"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-attribs" name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a3831583a91914988897a4cc8748fda43" id="r_a3831583a91914988897a4cc8748fda43"><td class="memItemLeft" align="right" valign="top"><a id="a3831583a91914988897a4cc8748fda43" name="a3831583a91914988897a4cc8748fda43"></a>
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>parent</b></td></tr>
<tr class="memdesc:a3831583a91914988897a4cc8748fda43"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores parent of every vertex and for root its own index. The root is technically not its own parent, but it's very practical for the lowest common ancestor algorithm. <br /></td></tr>
<tr class="separator:a3831583a91914988897a4cc8748fda43"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2ee3ad1161ac2532da30c3e22c265ad3" id="r_a2ee3ad1161ac2532da30c3e22c265ad3"><td class="memItemLeft" align="right" valign="top"><a id="a2ee3ad1161ac2532da30c3e22c265ad3" name="a2ee3ad1161ac2532da30c3e22c265ad3"></a>
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>level</b></td></tr>
<tr class="memdesc:a2ee3ad1161ac2532da30c3e22c265ad3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores the distance from the root. <br /></td></tr>
<tr class="separator:a2ee3ad1161ac2532da30c3e22c265ad3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab22a97bf6209a085fc2d788c3c0dacbe" id="r_ab22a97bf6209a085fc2d788c3c0dacbe"><td class="memItemLeft" align="right" valign="top"><a id="ab22a97bf6209a085fc2d788c3c0dacbe" name="ab22a97bf6209a085fc2d788c3c0dacbe"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>root</b></td></tr>
<tr class="memdesc:ab22a97bf6209a085fc2d788c3c0dacbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Index of the root vertex. <br /></td></tr>
<tr class="separator:ab22a97bf6209a085fc2d788c3c0dacbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_attribs_classgraph_1_1_graph"><td colspan="2" onclick="javascript:dynsection.toggleInherit('pub_attribs_classgraph_1_1_graph')"><img src="../../closed.png" alt="-"/>&#160;Public Attributes inherited from <a class="el" href="../../dc/d61/classgraph_1_1_graph.html">graph::Graph&lt; T &gt;</a></td></tr>
<tr class="memitem:a59940c462861f2fcf4951d1b6c084e6a inherit pub_attribs_classgraph_1_1_graph" id="r_a59940c462861f2fcf4951d1b6c084e6a"><td class="memItemLeft" align="right" valign="top">
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; int &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>neighbors</b></td></tr>
<tr class="memdesc:a59940c462861f2fcf4951d1b6c084e6a inherit pub_attribs_classgraph_1_1_graph"><td class="mdescLeft">&#160;</td><td class="mdescRight">for each vertex it stores a list indicies of its neighbors <br /></td></tr>
<tr class="separator:a59940c462861f2fcf4951d1b6c084e6a inherit pub_attribs_classgraph_1_1_graph"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pro-methods" name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:ae6928f3ebd491541e9570e746b877c1e" id="r_ae6928f3ebd491541e9570e746b877c1e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae6928f3ebd491541e9570e746b877c1e">populate_parents</a> ()</td></tr>
<tr class="memdesc:ae6928f3ebd491541e9570e746b877c1e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculate the parents for all the vertices in the tree. Implements the breadth first search algorithm starting from the root vertex searching the entire tree and labeling parents for all vertices. <br /></td></tr>
<tr class="separator:ae6928f3ebd491541e9570e746b877c1e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Representation of a rooted tree. For every vertex its parent is precalculated. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="aacdeecac857623e9fbfe92590f3c504d" name="aacdeecac857623e9fbfe92590f3c504d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aacdeecac857623e9fbfe92590f3c504d">&#9670;&#160;</a></span>RootedTree()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">graph::RootedTree::RootedTree </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; int, int &gt; &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>undirected_edges</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>root_</em></span>&#160;)</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Constructs the tree by calculating parent for every vertex. Assumes a valid description of a tree is provided. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">undirected_edges</td><td>list of graph's undirected edges </td></tr>
<tr><td class="paramname">root_</td><td>index of the root vertex </td></tr>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 95</span> : <a class="code hl_class" href="../../da/d9a/class_graph.html">Graph</a>(undirected_edges.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>() + 1, undirected_edges), <a class="code hl_variable" href="#ab22a97bf6209a085fc2d788c3c0dacbe">root</a>(root_) {</div>
<div class="line"><span class="lineno"> 96</span> <a class="code hl_function" href="#ae6928f3ebd491541e9570e746b877c1e">populate_parents</a>();</div>
<div class="line"><span class="lineno"> 97</span> }</div>
<div class="ttc" id="aclass_graph_html"><div class="ttname"><a href="../../da/d9a/class_graph.html">Graph</a></div><div class="ttdef"><b>Definition</b> bellman_ford.cpp:13</div></div>
<div class="ttc" id="aclassgraph_1_1_rooted_tree_html_ab22a97bf6209a085fc2d788c3c0dacbe"><div class="ttname"><a href="#ab22a97bf6209a085fc2d788c3c0dacbe">graph::RootedTree::root</a></div><div class="ttdeci">int root</div><div class="ttdoc">Index of the root vertex.</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:108</div></div>
<div class="ttc" id="aclassgraph_1_1_rooted_tree_html_ae6928f3ebd491541e9570e746b877c1e"><div class="ttname"><a href="#ae6928f3ebd491541e9570e746b877c1e">graph::RootedTree::populate_parents</a></div><div class="ttdeci">void populate_parents()</div><div class="ttdoc">Calculate the parents for all the vertices in the tree. Implements the breadth first search algorithm...</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:117</div></div>
<div class="ttc" id="asize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/size.html">std::vector::size</a></div><div class="ttdeci">T size(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d0/d58/classgraph_1_1_rooted_tree_aacdeecac857623e9fbfe92590f3c504d_cgraph.svg" width="100%" height="487"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
</div>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ae6928f3ebd491541e9570e746b877c1e" name="ae6928f3ebd491541e9570e746b877c1e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6928f3ebd491541e9570e746b877c1e">&#9670;&#160;</a></span>populate_parents()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void graph::RootedTree::populate_parents </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Calculate the parents for all the vertices in the tree. Implements the breadth first search algorithm starting from the root vertex searching the entire tree and labeling parents for all vertices. </p>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 117</span> {</div>
<div class="line"><span class="lineno"> 118</span> <span class="comment">// Initialize the vector with -1 which indicates the vertex</span></div>
<div class="line"><span class="lineno"> 119</span> <span class="comment">// wasn&#39;t yet visited.</span></div>
<div class="line"><span class="lineno"> 120</span> <a class="code hl_variable" href="#a3831583a91914988897a4cc8748fda43">parent</a> = <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int&gt;</a>(<a class="code hl_function" href="../../dc/d61/classgraph_1_1_graph.html#a8930d1470d132b19e430d1c71f94c904">number_of_vertices</a>(), -1);</div>
<div class="line"><span class="lineno"> 121</span> <a class="code hl_variable" href="#a2ee3ad1161ac2532da30c3e22c265ad3">level</a> = <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int&gt;</a>(<a class="code hl_function" href="../../dc/d61/classgraph_1_1_graph.html#a8930d1470d132b19e430d1c71f94c904">number_of_vertices</a>());</div>
<div class="line"><span class="lineno"> 122</span> <a class="code hl_variable" href="#a3831583a91914988897a4cc8748fda43">parent</a>[<a class="code hl_variable" href="#ab22a97bf6209a085fc2d788c3c0dacbe">root</a>] = <a class="code hl_variable" href="#ab22a97bf6209a085fc2d788c3c0dacbe">root</a>;</div>
<div class="line"><span class="lineno"> 123</span> <a class="code hl_variable" href="#a2ee3ad1161ac2532da30c3e22c265ad3">level</a>[<a class="code hl_variable" href="#ab22a97bf6209a085fc2d788c3c0dacbe">root</a>] = 0;</div>
<div class="line"><span class="lineno"> 124</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue.html">std::queue&lt;int&gt;</a> queue_of_vertices;</div>
<div class="line"><span class="lineno"> 125</span> queue_of_vertices.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/push.html">push</a>(<a class="code hl_variable" href="#ab22a97bf6209a085fc2d788c3c0dacbe">root</a>);</div>
<div class="line"><span class="lineno"> 126</span> <span class="keywordflow">while</span> (!queue_of_vertices.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/empty.html">empty</a>()) {</div>
<div class="line"><span class="lineno"> 127</span> <span class="keywordtype">int</span> vertex = queue_of_vertices.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/front.html">front</a>();</div>
<div class="line"><span class="lineno"> 128</span> queue_of_vertices.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/pop.html">pop</a>();</div>
<div class="line"><span class="lineno"> 129</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> neighbor : <a class="code hl_variable" href="../../dc/d61/classgraph_1_1_graph.html#a59940c462861f2fcf4951d1b6c084e6a">neighbors</a>[vertex]) {</div>
<div class="line"><span class="lineno"> 130</span> <span class="comment">// As long as the vertex was not yet visited.</span></div>
<div class="line"><span class="lineno"> 131</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="#a3831583a91914988897a4cc8748fda43">parent</a>[neighbor] == -1) {</div>
<div class="line"><span class="lineno"> 132</span> <a class="code hl_variable" href="#a3831583a91914988897a4cc8748fda43">parent</a>[neighbor] = vertex;</div>
<div class="line"><span class="lineno"> 133</span> <a class="code hl_variable" href="#a2ee3ad1161ac2532da30c3e22c265ad3">level</a>[neighbor] = <a class="code hl_variable" href="#a2ee3ad1161ac2532da30c3e22c265ad3">level</a>[vertex] + 1;</div>
<div class="line"><span class="lineno"> 134</span> queue_of_vertices.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/push.html">push</a>(neighbor);</div>
<div class="line"><span class="lineno"> 135</span> }</div>
<div class="line"><span class="lineno"> 136</span> }</div>
<div class="line"><span class="lineno"> 137</span> }</div>
<div class="line"><span class="lineno"> 138</span> }</div>
<div class="ttc" id="aclassgraph_1_1_graph_html_a59940c462861f2fcf4951d1b6c084e6a"><div class="ttname"><a href="../../dc/d61/classgraph_1_1_graph.html#a59940c462861f2fcf4951d1b6c084e6a">graph::Graph::neighbors</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; int &gt; &gt; neighbors</div><div class="ttdoc">for each vertex it stores a list indicies of its neighbors</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:77</div></div>
<div class="ttc" id="aclassgraph_1_1_graph_html_a8930d1470d132b19e430d1c71f94c904"><div class="ttname"><a href="../../dc/d61/classgraph_1_1_graph.html#a8930d1470d132b19e430d1c71f94c904">graph::Graph::number_of_vertices</a></div><div class="ttdeci">int number_of_vertices() const</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:74</div></div>
<div class="ttc" id="aclassgraph_1_1_rooted_tree_html_a2ee3ad1161ac2532da30c3e22c265ad3"><div class="ttname"><a href="#a2ee3ad1161ac2532da30c3e22c265ad3">graph::RootedTree::level</a></div><div class="ttdeci">std::vector&lt; int &gt; level</div><div class="ttdoc">Stores the distance from the root.</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:106</div></div>
<div class="ttc" id="aclassgraph_1_1_rooted_tree_html_a3831583a91914988897a4cc8748fda43"><div class="ttname"><a href="#a3831583a91914988897a4cc8748fda43">graph::RootedTree::parent</a></div><div class="ttdeci">std::vector&lt; int &gt; parent</div><div class="ttdoc">Stores parent of every vertex and for root its own index. The root is technically not its own parent,...</div><div class="ttdef"><b>Definition</b> lowest_common_ancestor.cpp:104</div></div>
<div class="ttc" id="aempty_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/empty.html">std::queue::empty</a></div><div class="ttdeci">T empty(T... args)</div></div>
<div class="ttc" id="afront_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/front.html">std::queue::front</a></div><div class="ttdeci">T front(T... args)</div></div>
<div class="ttc" id="apop_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/pop.html">std::queue::pop</a></div><div class="ttdeci">T pop(T... args)</div></div>
<div class="ttc" id="apush_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/push.html">std::queue::push</a></div><div class="ttdeci">T push(T... args)</div></div>
<div class="ttc" id="aqueue_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue.html">std::queue</a></div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/d58/classgraph_1_1_rooted_tree_ae6928f3ebd491541e9570e746b877c1e_cgraph.svg" width="507" height="250"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>graph/<a class="el" href="../../de/dde/lowest__common__ancestor_8cpp.html">lowest_common_ancestor.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../df/dce/namespacegraph.html">graph</a></li><li class="navelem"><a class="el" href="../../d0/d58/classgraph_1_1_rooted_tree.html">RootedTree</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.12.0 </li>
</ul>
</div>
</body>
</html>