50#include <lal/graphs/tree.hpp> 
   51#include <lal/graphs/rooted_tree.hpp> 
   52#include <lal/detail/graphs/traversal.hpp> 
   53#include <lal/detail/data_array.hpp> 
   72    std::enable_if_t< std::is_base_of_v<graphs::tree, tree_t>, 
bool> = 
true 
   77    const auto ccsize = t.get_num_nodes_component(x);
 
   78    if (ccsize == 1) { 
return 0; }
 
   79    if (ccsize == 2) { 
return 1; }
 
   80    if (ccsize == 3) { 
return 2; }
 
   83    const uint64_t n = t.get_num_nodes();
 
   87    if constexpr (std::is_base_of_v<graphs::rooted_tree, tree_t>) {
 
   98    ( [&](
const auto&, 
node, 
node v, 
bool) { farthest_from_x = v; } );
 
  102    uint64_t diameter = 0;
 
  109    [&](
const auto&, 
node u, 
node v, 
bool) {
 
  110        distance[v] = distance[u] + 1; diameter = std::max(diameter, distance[v]); }
 
Abstract graph Breadth-First Search traversal.
Definition: traversal.hpp:89
 
void clear_queue() noexcept
Clear the memory allocated for this structure.
Definition: traversal.hpp:223
 
void start_at(node source) noexcept
Start traversal at a given node.
Definition: traversal.hpp:152
 
void set_process_neighbour(const BFS_process_two &f) noexcept
Set the function that controls the processing of the current neighbour.
Definition: traversal.hpp:193
 
void clear_visited() noexcept
Sets all nodes to not visited.
Definition: traversal.hpp:216
 
void set_use_rev_edges(bool use) noexcept
Set whether the traversal can use reversed edges.
Definition: traversal.hpp:173
 
uint64_t tree_diameter(const tree_t &t, node x) noexcept
Calculate the diameter of a tree.
Definition: tree_diameter.hpp:74
 
Main namespace of the library.
Definition: basic_types.hpp:50
 
uint64_t node
Node type. See Node / Vertex page for further details.
Definition: basic_types.hpp:53
 
Wrapper of a C array for autmatic deallocation of memory.
Definition: data_array.hpp:59