52#include <lal/graphs/rooted_tree.hpp>
53#include <lal/detail/macros/basic_convert.hpp>
54#include <lal/detail/data_array.hpp>
76 std::enable_if_t< std::is_base_of_v<graphs::tree, tree_t>,
bool> =
true
81 if (t1.get_num_nodes() != t2.get_num_nodes()) {
return 1; }
83 const uint64_t n = t1.get_num_nodes();
86 if (n <= 2) {
return 0; }
92 uint64_t maxdeg_t1 = 0;
93 uint64_t maxdeg_t2 = 0;
94 for (
node u = 0; u < n; ++u) {
95 const uint64_t ku1 =
to_uint64(t1.get_degree(u));
96 const uint64_t ku2 =
to_uint64(t2.get_degree(u));
98 nL_t1 += t1.get_degree(u) == 1;
99 nL_t2 += t2.get_degree(u) == 1;
102 maxdeg_t1 = (maxdeg_t1 < ku1 ? ku1 : maxdeg_t1);
103 maxdeg_t2 = (maxdeg_t2 < ku2 ? ku2 : maxdeg_t2);
107 if (nL_t1 != nL_t2) {
return 1; }
109 if (maxdeg_t1 != maxdeg_t2) {
return 1; }
111 if (k2_t1 != k2_t2) {
return 1; }
140 std::string *
const aux_memory_for_names,
141 std::string *
const keep_name_of
145 if (t.get_out_degree(u) == 0) {
146 keep_name_of[u] =
"10";
151 const std::size_t begin_idx = idx;
152 for (
node v : t.get_out_neighbours(u)) {
156 aux_memory_for_names[idx] = keep_name_of[v];
159 std::sort(&aux_memory_for_names[begin_idx], &aux_memory_for_names[idx]);
162 std::string name =
"1";
163 for (std::size_t j = begin_idx; j < idx; ++j) {
164 name += aux_memory_for_names[j];
167 keep_name_of[u] = name;
190 if (t.get_out_degree(u) == 0) {
191 return std::string(
"10");
195 const std::size_t begin_idx = idx;
196 for (
node v : t.get_out_neighbours(u)) {
201 std::sort(&names[begin_idx], &names[idx]);
204 std::string name =
"1";
205 for (std::size_t j = begin_idx; j < idx; ++j) {
220 if (discard == 0) {
return true; }
221 if (discard == 1) {
return false; }
224 const std::string name_r1 =
assign_name(t1, t1.get_root(), names.
begin(), 0);
225 const std::string name_r2 =
assign_name(t2, t2.get_root(), names.
begin(), 0);
226 return name_r1 == name_r2;
Rooted tree graph class.
Definition: rooted_tree.hpp:103
char fast_non_iso(const tree_t &t1, const tree_t &t2) noexcept
Fast tree non-isomorphism test.
Definition: tree_isomorphism.hpp:78
bool are_full_trees_isomorphic(const graphs::rooted_tree &t1, const graphs::rooted_tree &t2) noexcept
Test whether two rooted trees are isomorphic or not.
Definition: tree_isomorphism.hpp:216
std::string assign_name(const graphs::rooted_tree &t, node u, std::string *const names, std::size_t idx) noexcept
Assigns a name to node 'u', root of the current subtree.
Definition: tree_isomorphism.hpp:187
constexpr uint64_t to_uint64(const T &t) noexcept
Conversion to uint64_t.
Definition: basic_convert.hpp:57
void assign_name_and_keep(const graphs::rooted_tree &t, node u, std::size_t idx, std::string *const aux_memory_for_names, std::string *const keep_name_of) noexcept
Assigns a name to node 'u', root of the current subtree.
Definition: tree_isomorphism.hpp:137
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
T * begin() noexcept
Non-constant raw pointer to first element.
Definition: data_array.hpp:291