Now truly finishing the refactoring
This commit is contained in:
@ -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() {
|
||||
|
||||
@ -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<G> RSDot<'_, G>
|
||||
impl<G> Dot<'_, G>
|
||||
where
|
||||
G: IntoNodeReferences + IntoEdgeReferences + NodeIndexable + GraphProp + DataMap,
|
||||
{
|
||||
@ -254,7 +254,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<G> fmt::Display for RSDot<'_, G>
|
||||
impl<G> fmt::Display for Dot<'_, G>
|
||||
where
|
||||
G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap,
|
||||
G::EdgeWeight: fmt::Display,
|
||||
@ -265,7 +265,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<G> fmt::LowerHex for RSDot<'_, G>
|
||||
impl<G> fmt::LowerHex for Dot<'_, G>
|
||||
where
|
||||
G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap,
|
||||
G::EdgeWeight: fmt::LowerHex,
|
||||
@ -276,7 +276,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<G> fmt::UpperHex for RSDot<'_, G>
|
||||
impl<G> fmt::UpperHex for Dot<'_, G>
|
||||
where
|
||||
G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap,
|
||||
G::EdgeWeight: fmt::UpperHex,
|
||||
@ -287,7 +287,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<G> fmt::Debug for RSDot<'_, G>
|
||||
impl<G> fmt::Debug for Dot<'_, G>
|
||||
where
|
||||
G: IntoEdgeReferences + IntoNodeReferences + NodeIndexable + GraphProp + DataMap,
|
||||
G::EdgeWeight: fmt::Debug,
|
||||
@ -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<String, String, Directed, u32>;
|
||||
type RSformatNodeTy<'a> =
|
||||
dyn Fn(
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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<String>) -> 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<String>) -> Option<IdType> {
|
||||
@ -44,15 +44,15 @@ impl Translator {
|
||||
|
||||
/// converts an id into the corresponding string
|
||||
pub fn decode(&self, el: IdType) -> Option<String> {
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user