summaryrefslogtreecommitdiff
path: root/graph/src/adlist.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-12-14 23:48:22 +0800
committerJSDurand <mmemmew@gmail.com>2022-12-14 23:48:22 +0800
commit9f1c88b863e247da3cd60d2792a7a13b18e25e53 (patch)
treed29c0e19793a88a1de6898fdfd2a376fca21378f /graph/src/adlist.rs
parentcb7bcfad4ab0041aaf3fde3185e27ee46bb37788 (diff)
a temporary check point
just to save things in a commit
Diffstat (limited to 'graph/src/adlist.rs')
-rw-r--r--graph/src/adlist.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/graph/src/adlist.rs b/graph/src/adlist.rs
index c16ceb2..18ad770 100644
--- a/graph/src/adlist.rs
+++ b/graph/src/adlist.rs
@@ -102,6 +102,14 @@ impl ExtGraph for ALGraph {
}
}
+// TODO: Add a way to build a graph by its raw adjacency list representation.
+impl From<Vec<Vec<usize>>> for ALGraph {
+ fn from(adlist: Vec<Vec<usize>>) -> Self {
+ let nodes: Vec<ALNode> = adlist.iter().cloned().map(ALNode::new).collect();
+ Self { nodes }
+ }
+}
+
#[cfg(test)]
mod algraph_test {
use super::*;