1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::graph::{ImageEdge, ImageNode};

/// The magic part of the graph segmentation, i.e. s given two nodes decide
/// whether to add an edge between them (i.e. merge the corresponding segments).
/// See the paper by Felzenswalb and Huttenlocher for details.
pub trait NodeMerging {
    /// Decide whether to merge the two segments corresponding to the given nodes or not.
    ///
    /// # Arguments
    ///
    /// * `s_n` - Node representing the first segment.
    /// * `s_m` - Node representing the second segment.
    /// * `e` - The edge between the two segments.
    ///
    /// # Returns
    ///
    /// `true` if merge
    // TODO: Rename the method.
    // TODO: Update the documentation on the return value.
    fn should_merge(&self, s_n: &ImageNode, s_m: &ImageNode, e: &ImageEdge) -> bool;
}