frequenz_microgrid_component_graph/
graph.rs1mod creation;
8mod meter_roles;
9mod retrieval;
10mod validation;
11
12mod formulas;
13pub mod iterators;
14
15use crate::{ComponentGraphConfig, Edge, Node};
16pub use formulas::{AggregationFormula, CoalesceFormula, Formula};
17use petgraph::graph::{DiGraph, NodeIndex};
18use std::collections::HashMap;
19
20pub(crate) type NodeIndexMap = HashMap<u64, NodeIndex>;
25
26pub(crate) type EdgeMap<E> = HashMap<(NodeIndex, NodeIndex), E>;
32
33pub struct ComponentGraph<N, E>
36where
37 N: Node,
38 E: Edge,
39{
40 graph: DiGraph<N, ()>,
41 node_indices: NodeIndexMap,
42 root_id: u64,
43 edges: EdgeMap<E>,
44 config: ComponentGraphConfig,
45}
46
47impl<N, E> Clone for ComponentGraph<N, E>
50where
51 N: Node + Clone,
52 E: Edge + Clone,
53{
54 fn clone(&self) -> Self {
55 Self {
56 graph: self.graph.clone(),
57 node_indices: self.node_indices.clone(),
58 root_id: self.root_id,
59 edges: self.edges.clone(),
60 config: self.config.clone(),
61 }
62 }
63}
64
65#[cfg(test)]
66mod test_utils;