summaryrefslogtreecommitdiffstats
path: root/vendor/gsgdt/src/multi_graph.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gsgdt/src/multi_graph.rs')
-rw-r--r--vendor/gsgdt/src/multi_graph.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/gsgdt/src/multi_graph.rs b/vendor/gsgdt/src/multi_graph.rs
new file mode 100644
index 000000000..f0200a318
--- /dev/null
+++ b/vendor/gsgdt/src/multi_graph.rs
@@ -0,0 +1,33 @@
+use crate::graph::*;
+use std::io::{self, Write};
+use serde::{Deserialize, Serialize};
+
+/// A collection of graphs.
+#[derive(Deserialize, Serialize)]
+pub struct MultiGraph {
+ name: String,
+ graphs: Vec<Graph>,
+}
+
+impl MultiGraph {
+ pub fn new(name: String, graphs: Vec<Graph>) -> MultiGraph {
+ MultiGraph { name, graphs }
+ }
+
+ pub fn to_dot<W: Write>(&self, w: &mut W, settings: &GraphvizSettings) -> io::Result<()> {
+ let subgraphs = self.graphs.len() > 1;
+ if subgraphs {
+ writeln!(w, "digraph {} {{", self.name)?;
+ }
+
+ for graph in &self.graphs {
+ graph.to_dot(w, settings, subgraphs)?;
+ }
+
+ if subgraphs {
+ writeln!(w, "}}")?;
+ }
+
+ Ok(())
+ }
+}