26#ifndef LIBSEMIGROUPS_DETAIL_NODE_MANAGED_GRAPH_HPP_
27#define LIBSEMIGROUPS_DETAIL_NODE_MANAGED_GRAPH_HPP_
40#include "libsemigroups/presentation.hpp"
41#include "libsemigroups/runner.hpp"
42#include "libsemigroups/types.hpp"
43#include "libsemigroups/word-graph.hpp"
45#include "felsch-graph.hpp"
46#include "node-manager.hpp"
49#include "word-graph-with-sources.hpp"
54 template <
typename BaseGraph>
55 class NodeManagedGraph :
public BaseGraph,
56 public NodeManager<typename BaseGraph::node_type>,
63 using node_type =
typename BaseGraph::node_type;
64 using base_Graph_type = BaseGraph;
67 std::is_base_of<WordGraphWithSources<node_type>, BaseGraph>::value,
68 "the template parameter BaseGraph must be derived from "
69 "WordGraphWithSources<node_type>");
76 using Coincidence = std::pair<node_type, node_type>;
77 using Coincidences = std::stack<Coincidence>;
78 struct CollectCoincidences;
98 using BaseGraph::out_degree;
99 using BaseGraph::target_no_checks;
100 using NodeManager<node_type>::cursor;
101 using NodeManager<node_type>::lookahead_cursor;
108 NodeManagedGraph& init();
110 NodeManagedGraph(NodeManagedGraph
const&);
111 NodeManagedGraph(NodeManagedGraph&&);
112 NodeManagedGraph& operator=(NodeManagedGraph
const&);
113 NodeManagedGraph& operator=(NodeManagedGraph&&);
117 template <
typename OtherNode>
118 explicit NodeManagedGraph(WordGraph<OtherNode>
const& ad)
119 : BaseGraph(ad), NodeManager<node_type>() {
121 NodeManager<node_type>::add_active_nodes(
127 template <
typename OtherNode>
128 NodeManagedGraph& operator=(WordGraph<OtherNode>
const& wg) {
131 NodeManager<node_type>::add_active_nodes(
136 NodeManagedGraph& reserve(
size_t n);
142 [[nodiscard]]
bool operator==(WordGraph<node_type>
const& that)
const {
143 return static_cast<WordGraph<node_type> const&
>(*this) == that;
150 NodeManagedGraph& large_collapse(
size_t val)
noexcept {
151 _settings.large_collapse = val;
155 [[nodiscard]]
size_t large_collapse() const noexcept {
156 return _settings.large_collapse;
163 [[nodiscard]] Stats& stats() noexcept {
167 void stats_check_point()
const;
173 node_type new_node();
175 template <
bool RegisterDefs = false>
176 [[nodiscard]] std::pair<bool, node_type>
177 complete_path(node_type c,
178 word_type::const_iterator first,
179 word_type::const_iterator last)
noexcept;
181 void merge_nodes_no_checks(node_type x, node_type y) {
182 _coinc.emplace(x, y);
185 template <
bool RegisterDefs>
186 void process_coincidences();
188 void permute_nodes_no_checks(std::vector<node_type>
const& p,
189 std::vector<node_type>
const& q) {
190 BaseGraph::permute_nodes_no_checks(
191 p, q, NodeManager<node_type>::number_of_nodes_active());
192 NodeManager<node_type>::apply_permutation(p);
197 void swap_nodes_no_checks(node_type c, node_type d);
203 void report_progress_from_thread()
const;
206 namespace node_managed_graph {
207 template <
typename BaseGraph>
208 typename BaseGraph::node_type
209 random_active_node(NodeManagedGraph<BaseGraph>
const& nmg);
216#include "node-managed-graph.tpp"
size_type number_of_nodes() const noexcept
Returns the number of nodes.
Definition word-graph.hpp:747
Namespace for everything in the libsemigroups library.
Definition action.hpp:44