diff --git a/src/rsprocess/bisimilarity/test_paige_tarjan.rs b/src/rsprocess/bisimilarity/test_paige_tarjan.rs index 6d11437..905cc6c 100644 --- a/src/rsprocess/bisimilarity/test_paige_tarjan.rs +++ b/src/rsprocess/bisimilarity/test_paige_tarjan.rs @@ -1,4 +1,5 @@ -use super::bisimilarity_paige_tarkan::{bisimilarity, bisimilarity_ignore_labels}; +use super::bisimilarity_paige_tarkan::{bisimilarity, + bisimilarity_ignore_labels}; #[test] fn identity_paige_tarjan() { diff --git a/src/rsprocess/rsdot.rs b/src/rsprocess/dot.rs similarity index 97% rename from src/rsprocess/rsdot.rs rename to src/rsprocess/dot.rs index d7ecd82..1f30625 100644 --- a/src/rsprocess/rsdot.rs +++ b/src/rsprocess/dot.rs @@ -16,7 +16,7 @@ use petgraph:: NodeRef, }}; -pub struct RSDot<'a, G> +pub struct Dot<'a, G> where G: IntoEdgeReferences + IntoNodeReferences + DataMap, { @@ -30,14 +30,14 @@ static TYPE: [&str; 2] = ["graph", "digraph"]; static EDGE: [&str; 2] = ["--", "->"]; static INDENT: &str = " "; -impl<'a, G> RSDot<'a, G> +impl<'a, G> Dot<'a, G> where G: IntoNodeReferences + IntoEdgeReferences + DataMap, { /// Create a `Dot` formatting wrapper with default configuration. #[inline] pub fn new(graph: G) -> Self { - RSDot { + Dot { graph, get_edge_attributes: &|_, _| String::new(), get_node_attributes: &|_, _| String::new(), @@ -49,7 +49,7 @@ where #[inline] pub fn with_config(graph: G, config: &'a [Config]) -> Self { let config = Configs::extract(config); - RSDot { + Dot { graph, get_edge_attributes: &|_, _| String::new(), get_node_attributes: &|_, _| String::new(), @@ -65,7 +65,7 @@ where get_node_attributes: &'a dyn Fn(G, G::NodeRef) -> String, ) -> Self { let config = Configs::extract(config); - RSDot { + Dot { graph, get_edge_attributes, get_node_attributes, @@ -167,7 +167,7 @@ macro_rules! make_config_struct { make_config_struct!(); -impl RSDot<'_, G> +impl Dot<'_, G> where G: IntoNodeReferences + IntoEdgeReferences + NodeIndexable + GraphProp + DataMap, { @@ -254,7 +254,7 @@ where } } -impl fmt::Display for RSDot<'_, G> +impl fmt::Display for Dot<'_, G> where G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap, G::EdgeWeight: fmt::Display, @@ -265,7 +265,7 @@ where } } -impl fmt::LowerHex for RSDot<'_, G> +impl fmt::LowerHex for Dot<'_, G> where G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap, G::EdgeWeight: fmt::LowerHex, @@ -276,7 +276,7 @@ where } } -impl fmt::UpperHex for RSDot<'_, G> +impl fmt::UpperHex for Dot<'_, G> where G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap, G::EdgeWeight: fmt::UpperHex, @@ -287,7 +287,7 @@ where } } -impl fmt::Debug for RSDot<'_, G> +impl fmt::Debug for Dot<'_, G> where G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap, G::EdgeWeight: fmt::Debug, diff --git a/src/rsprocess/graph.rs b/src/rsprocess/graph.rs index 932d317..a30fa1e 100644 --- a/src/rsprocess/graph.rs +++ b/src/rsprocess/graph.rs @@ -1,5 +1,6 @@ //! Definitions for generating graphs from a simulation. +use petgraph::visit::{IntoEdgeReferences, IntoNodeReferences}; use petgraph::{Graph, Directed}; use std::rc::Rc; @@ -437,8 +438,6 @@ impl EdgeDisplay { // Node ------------------------------------------------------------------------ -use petgraph::visit::{IntoEdgeReferences, IntoNodeReferences}; - type RSdotGraph = Graph; type RSformatNodeTy<'a> = dyn Fn( diff --git a/src/rsprocess/mod.rs b/src/rsprocess/mod.rs index 0b6f1dd..87919f2 100644 --- a/src/rsprocess/mod.rs +++ b/src/rsprocess/mod.rs @@ -16,7 +16,7 @@ pub mod bisimilarity; pub mod frequency; pub mod graph; pub mod presets; -pub mod rsdot; +pub mod dot; pub mod serialize; pub mod transitions; diff --git a/src/rsprocess/presets.rs b/src/rsprocess/presets.rs index 0f3d978..c49876f 100644 --- a/src/rsprocess/presets.rs +++ b/src/rsprocess/presets.rs @@ -12,7 +12,6 @@ use std::rc::Rc; use super::*; use super::graph::MapEdges; use super::set::Set; -use super::system; use super::translator::Translator; use super::super::grammar; @@ -626,7 +625,7 @@ pub fn dot( let edge_formatter = edge_color.generate(Rc::clone(&graph)); - let dot = rsdot::RSDot::with_attr_getters( + let dot = dot::Dot::with_attr_getters( &modified_graph, &[], &edge_formatter, diff --git a/src/rsprocess/translator.rs b/src/rsprocess/translator.rs index 9c75390..738712a 100644 --- a/src/rsprocess/translator.rs +++ b/src/rsprocess/translator.rs @@ -20,22 +20,22 @@ pub struct Translator { impl Translator { pub fn new() -> Self { - Translator { - strings: HashMap::from([("*".into(), 0)]), - reverse: HashMap::from([(0, "*".into())]), - last_id: 1, - } + Translator { + strings: HashMap::from([("*".into(), 0)]), + reverse: HashMap::from([(0, "*".into())]), + last_id: 1, + } } /// converts a string into an id pub fn encode(&mut self, s: impl Into) -> IdType { - let s = s.into(); - let id = *(self.strings.entry(s.clone()).or_insert({ - self.last_id += 1; - self.last_id - })); - self.reverse.insert(id, s.clone()); - id + let s = s.into(); + let id = *(self.strings.entry(s.clone()).or_insert({ + self.last_id += 1; + self.last_id + })); + self.reverse.insert(id, s.clone()); + id } pub fn encode_not_mut(&self, s: impl Into) -> Option { @@ -44,15 +44,15 @@ impl Translator { /// converts an id into the corresponding string pub fn decode(&self, el: IdType) -> Option { - self.reverse - .get(&el) - .map(|x| x.to_string()) + self.reverse + .get(&el) + .map(|x| x.to_string()) } } impl Default for Translator { fn default() -> Self { - Translator::new() + Translator::new() } } @@ -101,5 +101,3 @@ impl<'a, T> Formatter<'a, T> { Self { data, translator } } } - -