graphannis_core/graph/storage/
legacy.rs1use std::collections::HashMap;
8
9use rustc_hash::FxHashMap;
10
11use crate::{
12 annostorage::inmemory::AnnoStorageImpl,
13 types::{Edge, NodeID, NumValue},
14};
15
16use super::{
17 GraphStatistic,
18 linear::RelativePosition,
19 prepost::{OrderVecEntry, PrePost},
20};
21
22#[derive(Serialize, Deserialize, Clone)]
24pub(crate) struct GraphStatisticV1 {
25 pub cyclic: bool,
27
28 pub rooted_tree: bool,
30
31 pub nodes: usize,
33
34 pub avg_fan_out: f64,
36 pub fan_out_99_percentile: usize,
38
39 pub inverse_fan_out_99_percentile: usize,
41
42 pub max_fan_out: usize,
44 pub max_depth: usize,
46
47 pub dfs_visit_ratio: f64,
49}
50
51impl From<GraphStatisticV1> for GraphStatistic {
52 fn from(value: GraphStatisticV1) -> Self {
53 let root_nodes = if value.nodes > 0 { 1 } else { 0 };
54 Self {
55 cyclic: value.cyclic,
56 rooted_tree: value.rooted_tree,
57 nodes: value.nodes,
58 root_nodes,
59 avg_fan_out: value.avg_fan_out,
60 fan_out_99_percentile: value.fan_out_99_percentile,
61 inverse_fan_out_99_percentile: value.inverse_fan_out_99_percentile,
62 max_fan_out: value.max_fan_out,
63 max_depth: value.max_depth,
64 dfs_visit_ratio: value.dfs_visit_ratio,
65 }
66 }
67}
68
69#[derive(Serialize, Deserialize, Clone)]
71pub(crate) struct AdjacencyListStorageV1 {
72 pub(crate) edges: HashMap<NodeID, Vec<NodeID>>,
73 pub(crate) inverse_edges: HashMap<NodeID, Vec<NodeID>>,
74 pub(crate) annos: AnnoStorageImpl<Edge>,
75 pub(crate) stats: Option<GraphStatisticV1>,
76}
77
78#[derive(Serialize, Deserialize, Clone)]
81pub(crate) struct DenseAdjacencyListStorageV1 {
82 pub(crate) edges: Vec<Option<NodeID>>,
83 pub(crate) inverse_edges: HashMap<NodeID, Vec<NodeID>>,
84 pub(crate) annos: AnnoStorageImpl<Edge>,
85 pub(crate) stats: Option<GraphStatisticV1>,
86}
87
88#[derive(Serialize, Deserialize, Clone)]
90pub(crate) struct LinearGraphStorageV1<PosT: NumValue> {
91 pub(crate) node_to_pos: HashMap<NodeID, RelativePosition<PosT>>,
92 pub(crate) node_chains: HashMap<NodeID, Vec<NodeID>>,
93 pub(crate) annos: AnnoStorageImpl<Edge>,
94 pub(crate) stats: Option<GraphStatisticV1>,
95}
96
97#[derive(Serialize, Deserialize, Clone)]
99pub(crate) struct PrePostOrderStorageV1<OrderT: NumValue, LevelT: NumValue> {
100 pub(crate) node_to_order: FxHashMap<NodeID, Vec<PrePost<OrderT, LevelT>>>,
101 pub(crate) order_to_node: Vec<OrderVecEntry<OrderT, LevelT>>,
102 pub(crate) annos: AnnoStorageImpl<Edge>,
103 pub(crate) stats: Option<GraphStatisticV1>,
104}