oxicuda_graphalg/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum GraphalgError {
8 #[error("invalid graph: {0}")]
9 InvalidGraph(String),
10 #[error("negative weight detected on edge {edge:?}: {weight}")]
11 NegativeWeight { edge: (usize, usize), weight: f64 },
12 #[error("negative cycle detected in graph")]
13 NegativeCycle,
14 #[error("source node {node} out of range for graph of {n} nodes")]
15 SourceOutOfRange { node: usize, n: usize },
16 #[error("graph is disconnected: {0}")]
17 DisconnectedGraph(String),
18 #[error("graph is not bipartite: {0}")]
19 NotABipartiteGraph(String),
20 #[error("graph is not a DAG: a cycle was detected")]
21 NotADag,
22 #[error("invalid parameter: {0}")]
23 InvalidParameter(String),
24 #[error("numerical instability: {0}")]
25 NumericalInstability(String),
26 #[error("unsupported SM version: {0}")]
27 UnsupportedSmVersion(u32),
28 #[error("index {index} out of bounds for length {len}")]
29 IndexOutOfBounds { index: usize, len: usize },
30 #[error("empty input")]
31 EmptyInput,
32 #[error("algorithm did not converge after {iter} iterations")]
33 NotConverged { iter: usize },
34 #[error("not implemented: {0}")]
35 NotImplemented(String),
36 #[error("dimension mismatch: a={a}, b={b}")]
37 DimensionMismatch { a: usize, b: usize },
38 #[error("no solution exists: {0}")]
39 NoSolution(String),
40 #[error("invalid edge weight: {0}")]
41 InvalidEdgeWeight(String),
42 #[error("invalid configuration: {0}")]
43 InvalidConfiguration(String),
44}
45
46pub type GraphalgResult<T> = Result<T, GraphalgError>;