#[cfg(feature = "svg")]
use graphviz_rust::cmd::{CommandArg, Format};
use petgraph::dot::Dot;
use std::fmt::Debug;
#[cfg(feature = "svg")]
use std::vec;
use crate::graph::VizDotGraph;
impl<NodeWeight, EdgeWeight, IndexType, Direction> VizDotGraph<NodeWeight, EdgeWeight>
for petgraph::graph::Graph<NodeWeight, EdgeWeight, Direction, IndexType>
where
NodeWeight: Debug,
EdgeWeight: Debug,
IndexType: petgraph::graph::IndexType,
Direction: petgraph::EdgeType,
{
fn print(&self) -> String {
format!("{:?}", Dot::new(self))
}
#[cfg(feature = "svg")]
fn print_to_svg(&self, path: &str) -> Result<String, std::io::Error> {
graphviz_rust::exec_dot(
self.print(),
vec![
CommandArg::Format(Format::Svg),
CommandArg::Output(path.to_string()),
],
)
}
}