pub struct EdgeRule {
pub edge: String,
pub means: String,
pub forward: Option<f64>,
pub reverse: Option<f64>,
pub reason: String,
pub refused: bool,
}Expand description
One edge of the composed graph, and what the compiler does with it.
Every edge kind the graph declares gets a row, followed or not, which is the property
that makes this projection worth reading: an edge added to the graph and not to the
traversal table appears here as refused with a reason saying the compiler has no rule
for it, rather than being silently unfollowed. A table that only listed the edges it
followed could not tell you what it was ignoring.
forward and reverse are absent rather than zero when the edge is not followed that
way, so “not followed” is one representation and not two. means is the graph’s own
account of the relation; reason is this compiler’s account of why it is or is not
context, in both directions.
use majordomus_cli::devcontext::{edge_policy, policy, EdgeRule};
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let rules = policy(&ctx).unwrap();
// one row per edge kind the graph declares, followed or refused
let edges: &[EdgeRule] = &rules.edges;
assert!(!edges.is_empty(), "the graph declares edges");
for e in edges {
// the row always says what the relation is and what was decided about it
assert!(!e.means.is_empty() && !e.reason.is_empty(), "{}", e.edge);
if e.refused {
// not followed in either direction, and absent rather than zero
assert!(e.forward.is_none() && e.reverse.is_none(), "{}", e.edge);
assert!(edge_policy(&e.edge).is_none(), "{} is refused and in the table", e.edge);
} else {
// followed at least one way, at a weight the table declares
assert!(e.forward.is_some() || e.reverse.is_some(), "{}", e.edge);
let p = edge_policy(&e.edge).expect("a followed edge has a policy");
assert_eq!(e.forward, (p.forward > 0.0).then_some(p.forward));
assert_eq!(e.reverse, (p.reverse > 0.0).then_some(p.reverse));
}
}Fields§
§edge: StringThe edge kind, as the composed graph names it.
means: StringWhat the graph asserts by it.
forward: Option<f64>The relevance multiplier when followed source to target; absent when refused.
reverse: Option<f64>The multiplier when followed target to source; absent when refused.
reason: StringWhy the target is context for the source, or why the edge is refused.
refused: boolTrue when the compiler will not follow it in either direction.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EdgeRule
impl<'de> Deserialize<'de> for EdgeRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for EdgeRule
impl JsonSchema for EdgeRule
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more