Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the MAX level(depth) of a vertex in a boost graph
    primarykey
    data
    text
    <p>I am new to boost graphs and graph theory in general. As it happens my limited knowledge on terminology of graph algorithms is making things difficult for me. Anyways here is what I am trying to do.</p> <p>I am using <code>boost::adjacency_list</code> and let's say I have a vertex </p> <pre><code>struct Node { int level; } </code></pre> <p>Now I have a whole graph constructed and I want to find the level of each node. Level for me means here the maximum depth of a node from the root. For example consider the graph (assuming 118 is the root node)</p> <pre><code>118 -&gt; 122 118 -&gt; 120 122 -&gt; 120 122 -&gt; 121 121 -&gt; 125 121 -&gt; 123 123 -&gt; 125 125 -&gt; 124 </code></pre> <p>then level of <code>122 is 1, 120 is 2, 121 is 2, 123 is 3, 125 is 4, and 124 is 5</code>.</p> <p>Is there any algorithm in boost that lets me do this. My bet is that it is <code>boost::bredth_first_visit</code>. But I am not sure how to use it correctly so that it puts the correct values in <code>Node.level</code> while visiting. </p> <p>I found another post on stack overflow on similar issue and this was kind of the solution (it is not compiling for me.)</p> <pre><code>typedef boost::property_map&lt;TaskGraph, boost::vertex_color_t&gt;::type color_map_t; color_map_t colorMap; //Create a color map boost::breadth_first_visit(graph, *boost::vertices(graph).first, boost::color_map(colorMap)); </code></pre> <p>What I want to do is something like </p> <pre><code>boost::breadth_first_visit(graph, *boost::vertices(graph).first, /*What goes here so that Node.level gets the level*/); </code></pre> <p>Thanks for the help and sorry for the terminology. Not sure if <code>level</code> is the correct term in graph theory.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload