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
use std::collections::BTreeMap;
use nassun::package::Package;
use oro_common::CorgiManifest;
use petgraph::stable_graph::{EdgeIndex, NodeIndex};
use unicase::UniCase;
use crate::Graph;
#[derive(Debug, Clone)]
pub struct Node {
pub(crate) idx: NodeIndex,
pub(crate) package: Package,
pub(crate) manifest: CorgiManifest,
pub(crate) root: NodeIndex,
pub(crate) dependencies: BTreeMap<UniCase<String>, EdgeIndex>,
pub(crate) parent: Option<NodeIndex>,
pub(crate) children: BTreeMap<UniCase<String>, NodeIndex>,
}
impl Node {
pub(crate) fn new(package: Package, manifest: CorgiManifest) -> Self {
Self {
package,
manifest,
idx: NodeIndex::new(0),
root: NodeIndex::new(0),
parent: None,
children: BTreeMap::new(),
dependencies: BTreeMap::new(),
}
}
pub(crate) fn depth(&self, graph: &Graph) -> usize {
graph.node_parent_iter(self.idx).count() - 1
}
}