pub fn generate(mut self, model: &Model, label: &str) -> Result<String, anyhow::Error> {
        self.new_line("digraph G {");
        self.inc();
        self.new_line("compound = true");
        self.new_line("labeljust = l");
        self.new_line(&DotLabel::SingleRow(label.trim()).to_string());
        self.new_line("node [ shape = box ]");

        // list of quantifiers for adding the edges connecting them to their
        // input boxes after all boxes have been processed
        let mut quantifiers = Vec::new();

        model
            .visit_pre_boxes(&mut |b| -> Result<(), ()> {
                let box_id = b.id;

                self.new_line(&format!("subgraph cluster{} {{", box_id));
                self.inc();
                self.new_line(
                    &DotLabel::SingleRow(&format!("Box{}:{}", box_id, Self::get_box_title(&b)))
                        .to_string(),
                );
                self.new_line(&format!(
                    "boxhead{} [ shape = record, {} ]",
                    box_id,
                    Self::get_box_head(&b)
                ));

                self.new_line("{");
                self.inc();
                self.new_line("rank = same");

                if b.quantifiers.len() > 0 {
                    self.new_line("node [ shape = circle ]");
                }

                for q_id in b.quantifiers.iter() {
                    quantifiers.push(*q_id);

                    let q = model.get_quantifier(*q_id);
                    self.new_line(&format!(
                        "Q{0} [ {1} ]",
                        q_id,
                        DotLabel::SingleRow(&format!(
                            "Q{0}({1}){2}",
                            q_id,
                            q.quantifier_type,
                            Self::get_quantifier_alias(&q)
                        ))
                    ));
                }

                self.add_correlation_info(model, &b);

                self.dec();
                self.new_line("}");
                self.dec();
                self.new_line("}");

                Ok(())
            })
            .unwrap();

        if quantifiers.len() > 0 {
            self.new_line("edge [ arrowhead = none, style = dashed ]");
            for q_id in quantifiers.iter() {
                let q = model.get_quantifier(*q_id);
                self.new_line(&format!(
                    "Q{0} -> boxhead{1} [ lhead = cluster{1} ]",
                    q_id, q.input_box
                ));
            }
        }

        self.dec();
        self.new_line("}");
        self.new_line(""); // final empty line
        Ok(self.output)
    }
/// Generates a graphviz graph for the given model, labeled with `label`.
Generates a graphviz graph for the given model, labeled with `label`.
Generates a graphviz graph for the given model labeled with ` label ` .
pub fn generate(mut self, model: &Model, label: &str) -> Result<String, anyhow::Error> {
        self.new_line("digraph G {");
        self.inc();
        self.new_line("compound = true");
        self.new_line("labeljust = l");
        self.new_line(&DotLabel::SingleRow(label.trim()).to_string());
        self.new_line("node [ shape = box ]");
        // list of quantifiers for adding the edges connecting them to their
        // input boxes after all boxes have been processed
        let mut quantifiers = Vec::new();
        model
            .visit_pre_boxes(&mut |b| -> Result<(), ()> {
                let box_id = b.id;
                self.new_line(&format!("subgraph cluster{} {{", box_id));
                self.inc();
                self.new_line(
                    &DotLabel::SingleRow(&format!("Box{}:{}", box_id, Self::get_box_title(&b)))
                        .to_string(),
                );
                self.new_line(&format!(
                    "boxhead{} [ shape = record, {} ]",
                    box_id,
                    Self::get_box_head(&b)
                ));
                self.new_line("{");
                self.inc();
                self.new_line("rank = same");
                if b.quantifiers.len() > 0 {
                    self.new_line("node [ shape = circle ]");
                }
                for q_id in b.quantifiers.iter() {
                    quantifiers.push(*q_id);
                    let q = model.get_quantifier(*q_id);
                    self.new_line(&format!(
                        "Q{0} [ {1} ]",
                        q_id,
                        DotLabel::SingleRow(&format!(
                            "Q{0}({1}){2}",
                            q_id,
                            q.quantifier_type,
                            Self::get_quantifier_alias(&q)
                        ))
                    ));
                }
                self.add_correlation_info(model, &b);
                self.dec();
                self.new_line("}");
                self.dec();
                self.new_line("}");
                Ok(())
            })
            .unwrap();
        if quantifiers.len() > 0 {
            self.new_line("edge [ arrowhead = none, style = dashed ]");
            for q_id in quantifiers.iter() {
                let q = model.get_quantifier(*q_id);
                self.new_line(&format!(
                    "Q{0} -> boxhead{1} [ lhead = cluster{1} ]",
                    q_id, q.input_box
                ));
            }
        }
        self.dec();
        self.new_line("}");
        self.new_line(""); // final empty line
        Ok(self.output)
    }
pub fn generate ( mut self , model : & Model , label : & str ) -> Result < String , anyhow :: Error > { self . new_line ( " " ) ; self . inc ( ) ; self . new_line ( " " ) ; self . new_line ( " " ) ; self . new_line ( & DotLabel :: SingleRow ( label . trim ( ) ) . to_string ( ) ) ; self . new_line ( " " ) ; // list of quantifiers for adding the edges connecting them to their // input boxes after all boxes have been processed let mut quantifiers = Vec :: new ( ) ; model . visit_pre_boxes ( & mut | b | -> Result < ( ) , ( ) > { let box_id = b . id ; self . new_line ( & format ! ( " " box_id ) ) ; self . inc ( ) ; self . new_line ( & DotLabel :: SingleRow ( & format ! ( " " box_id Self get_box_title ( b ) ) ) . to_string ( ) , ) ; self . new_line ( & format ! ( " " box_id Self get_box_head ( b ) ) ) ; self . new_line ( " " ) ; self . inc ( ) ; self . new_line ( " " ) ; if b . quantifiers . len ( ) > 0 { self . new_line ( " " ) ; } for q_id in b . quantifiers . iter ( ) { quantifiers . push ( * q_id ) ; let q = model . get_quantifier ( * q_id ) ; self . new_line ( & format ! ( " " q_id DotLabel SingleRow ( format ( " " q_id q quantifier_type Self get_quantifier_alias ( q ) ) ) ) ) ; } self . add_correlation_info ( model , & b ) ; self . dec ( ) ; self . new_line ( " " ) ; self . dec ( ) ; self . new_line ( " " ) ; Ok ( ( ) ) } ) . unwrap ( ) ; if quantifiers . len ( ) > 0 { self . new_line ( " " ) ; for q_id in quantifiers . iter ( ) { let q = model . get_quantifier ( * q_id ) ; self . new_line ( & format ! ( " " q_id q input_box ) ) ; } } self . dec ( ) ; self . new_line ( " " ) ; self . new_line ( " " ) ; // final empty line Ok ( self . output ) }
Generates a graphviz graph for the given model, labeled with `label`.
Generates a graphviz graph for the given model labeled with ` label ` .
mut self
model
&Model
label
&str
mut self
model
&Model
label
&str