4 #include <unordered_map>
6 #include "internal/node.h"
35 int m_width, m_height;
36 std::unique_ptr<std::vector<Node_ptr>> m_nodes;
37 std::unordered_map<int32_t, int32_t> m_node_ids;
39 void hash_node_ids(
void);
42 inline Graph(std::unique_ptr<std::vector<Node_ptr>> &nodes,
int width,
int height)
43 : m_nodes(std::move(nodes)), m_width(width), m_height(height) {
47 bool add_edge(int32_t node_id1, int32_t node_id2);
48 bool merge_nodes(
const Node_ptr &node_to_keep,
const Node_ptr &node_to_remove);
50 void clear_unconnected_nodes();
52 inline const std::vector<Node_ptr> &get_nodes()
const {
56 bool all_areas_bigger_than(int32_t min_area);
57 inline const size_t size() {
58 return m_nodes->size();
61 void discover_edges(
const std::vector<int32_t> ®ion_labels,
const int32_t width,
62 const int32_t height);
63 void merge_small_area_nodes(
const int32_t min_area);
64 void compute_contours();