diff options
author | JSDurand <mmemmew@gmail.com> | 2023-01-20 13:48:26 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-01-20 13:48:26 +0800 |
commit | 18d7955b7d84c00467ede38baae53f4ce1fb6908 (patch) | |
tree | 97d0746b82816a21d980636e50f8cdbeb804b518 /graph/src/labelled/double.rs | |
parent | 8f8d3d1a3c276be4be2e5d2e767ada564c47279a (diff) |
chain: a prototype is added.
I have an ostensibly working prototype now.
Further tests are needed to make sure that the algorithm meets the
time complexity requirement, though.
Diffstat (limited to 'graph/src/labelled/double.rs')
-rw-r--r-- | graph/src/labelled/double.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/graph/src/labelled/double.rs b/graph/src/labelled/double.rs index 4ab8a38..174c8ef 100644 --- a/graph/src/labelled/double.rs +++ b/graph/src/labelled/double.rs @@ -150,6 +150,8 @@ impl<T: GraphLabel> Graph for DLGraph<T> { } fn print_viz(&self, filename: &str) -> Result<(), std::io::Error> { + let filename = format!("output/{filename}"); + let preamble = "digraph nfa { fontname=\"Helvetica,Arial,sans-serif\" node [fontname=\"Helvetica,Arial,sans-serif\"] @@ -170,14 +172,14 @@ impl<T: GraphLabel> Graph for DLGraph<T> { let result = format!("{preamble}{post}"); - if std::fs::metadata(filename).is_ok() { - std::fs::remove_file(filename)?; + if std::fs::metadata(&filename).is_ok() { + std::fs::remove_file(&filename)?; } let mut file = std::fs::File::options() .write(true) .create(true) - .open(filename)?; + .open(&filename)?; use std::io::Write; @@ -206,7 +208,7 @@ impl<'a> Iterator for LabelIndexIter<'a> { #[inline] fn next(&mut self) -> Option<Self::Item> { - self.iter.as_mut().and_then(|iterator| iterator.next()) + self.iter.as_mut().and_then(Iterator::next) } #[inline] @@ -242,7 +244,7 @@ impl<'a> From<&'a Set<usize>> for LabelIndexIter<'a> { } } -#[derive(Debug)] +#[derive(Debug, Clone)] /// A delegation of iterators. /// /// This is used to avoid a boxed pointer to an iterator. @@ -278,7 +280,7 @@ impl<'a, T> Iterator for LabelIter<'a, T> { } /// This is used to avoid a boxed pointer to an iterator. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct EdgeLabelIter<'a, T> { iter: Option<Iter<'a, T>>, } |