//! Edge kind: bidirectional vs directed. Type structure carries the
//! semantics — `a`/`b` are interchangeable, `from`/`to` are not.

use crate::board::ids::BoardNodeId;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum EdgeKind {
    Bidirectional { a: BoardNodeId, b: BoardNodeId },
    Directed      { from: BoardNodeId, to: BoardNodeId },
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn edge_kind_is_constructible() {
        let bi = EdgeKind::Bidirectional { a: BoardNodeId(0), b: BoardNodeId(1) };
        let dir = EdgeKind::Directed { from: BoardNodeId(0), to: BoardNodeId(1) };
        assert_ne!(bi, dir);
    }

    #[test]
    fn directed_endpoints_have_role_semantics() {
        let a = EdgeKind::Bidirectional { a: BoardNodeId(7), b: BoardNodeId(9) };
        let b = EdgeKind::Directed { from: BoardNodeId(7), to: BoardNodeId(9) };
        assert_ne!(a, b);
    }
}
