use thiserror::Error;
use crate::{HyperedgeIndex, VertexIndex};
#[derive(Clone, Debug, Eq, Error, PartialEq)]
pub enum HypergraphError<V, HE>
where
V: Copy + Eq,
HE: Copy + Eq,
{
#[error("HyperedgeIndex {0} was not found")]
HyperedgeIndexNotFound(HyperedgeIndex),
#[error("Internal hyperedge index {0} was not found")]
InternalHyperedgeIndexNotFound(usize),
#[error("Hyperedge weight {0} was not found")]
HyperedgeWeightNotFound(HE),
#[error("HyperedgeIndex {index:?} weight {weight:?} is unchanged (no-op)")]
HyperedgeWeightUnchanged { index: HyperedgeIndex, weight: HE },
#[error("HyperedgeIndex {0} vertices are unchanged (no-op)")]
HyperedgeVerticesUnchanged(HyperedgeIndex),
#[error("HyperedgeIndex {0} vertices are missing")]
HyperedgeCreationNoVertices(HE),
#[error("HyperedgeIndex {0} vertices are missing")]
HyperedgeUpdateNoVertices(HyperedgeIndex),
#[error("HyperedgeIndex {index:?} does not include vertices {vertices:?}")]
HyperedgeVerticesIndexesNotFound {
index: HyperedgeIndex,
vertices: Vec<VertexIndex>,
},
#[error(
"HyperedgeIndex {index:?} contraction of vertices {vertices:?} into vertex {target:?} is invalid"
)]
HyperedgeInvalidContraction {
index: HyperedgeIndex,
target: VertexIndex,
vertices: Vec<VertexIndex>,
},
#[error("Hyperedge weight {0} was already assigned")]
HyperedgeWeightAlreadyAssigned(HE),
#[error("At least two hyperedges must be provided to find their intersections")]
HyperedgesInvalidIntersections,
#[error("At least two hyperedges must be provided to be joined")]
HyperedgesInvalidJoin,
#[error("VertexIndex {0} was not found")]
VertexIndexNotFound(VertexIndex),
#[error("Internal vertex index {0} was not found")]
InternalVertexIndexNotFound(usize),
#[error("Vertex weight {0} was not found")]
VertexWeightNotFound(V),
#[error("VertexIndex {index:?} weight {weight:?} unchanged (no-op)")]
VertexWeightUnchanged { index: VertexIndex, weight: V },
#[error("Vertex weight {0} was already assigned")]
VertexWeightAlreadyAssigned(V),
}