1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Graph construction and validation errors.
//!
//! SPDX-License-Identifier: MIT OR Apache-2.0
use antecedent_core::{Lag, VariableId};
use thiserror::Error;
/// Graph-layer errors.
#[derive(Clone, Debug, Eq, PartialEq, Error)]
#[non_exhaustive]
pub enum GraphError {
/// Unknown dense node.
#[error("unknown dense node {id}")]
UnknownNode {
/// Dense id.
id: u32,
},
/// Unknown variable name at an API boundary.
#[error("unknown variable name '{name}'")]
UnknownVariableName {
/// Requested name.
name: String,
},
/// Edge would introduce a directed cycle.
#[error("edge {from}->{to} would create a cycle")]
Cycle {
/// Source dense id.
from: u32,
/// Target dense id.
to: u32,
},
/// Invalid endpoint combination for this graph class.
#[error("invalid endpoints: {message}")]
InvalidEndpoints {
/// Explanation.
message: &'static str,
},
/// Contemporaneous self-edge is invalid.
#[error("contemporaneous self-edge on {variable}")]
ContemporaneousSelfEdge {
/// Variable.
variable: VariableId,
},
/// Duplicate edge.
#[error("duplicate edge {from}->{to}")]
DuplicateEdge {
/// From.
from: u32,
/// To.
to: u32,
},
/// Lagged self-edge with lag 0.
#[error("invalid lag {lag}")]
InvalidLag {
/// Lag value.
lag: Lag,
},
/// Edge points from the future into the past (source lag nearer the present
/// than target lag).
#[error("edge {from}->{to} points from the future ({from_lag}) into the past ({to_lag})")]
FutureToPast {
/// Source dense id.
from: u32,
/// Target dense id.
to: u32,
/// Source lag.
from_lag: Lag,
/// Target lag.
to_lag: Lag,
},
/// Node capacity exceeded.
#[error("too many nodes")]
TooManyNodes,
/// Invalid selection-diagram metadata.
#[error("invalid selection diagram: {message}")]
InvalidSelectionDiagram {
/// Explanation.
message: String,
},
/// Bounded path search hit `max_paths` or `max_len` before exploring all candidates.
///
/// Returned when m-separation would otherwise conclude "separated" after an incomplete
/// search (an unexplored active path may still exist). Finding an active path remains
/// conclusive even under truncation.
#[error("path search budget exhausted (max_paths={max_paths}, max_len={max_len})")]
SearchBudgetExhausted {
/// Path-count budget.
max_paths: usize,
/// Path-length budget.
max_len: usize,
},
}