pub struct GraphMl<G>where
G: IntoEdgeReferences + IntoNodeReferences,{ /* private fields */ }
Expand description
GraphML output printer
See the main crate documentation for usage instructions and examples.
Implementations§
Source§impl<G> GraphMl<G>
impl<G> GraphMl<G>
Sourcepub fn pretty_print(self, state: bool) -> Self
pub fn pretty_print(self, state: bool) -> Self
Enable or disble pretty printing of the XML.
Pretty printing enables linebreaks and indentation.
Sourcepub fn export_edge_weights_display(self) -> Selfwhere
G::EdgeWeight: Display,
pub fn export_edge_weights_display(self) -> Selfwhere
G::EdgeWeight: Display,
Export the edge weights to GraphML.
This uses the Display
implementation of the edge weight type.
The attribute name defaults to “weight”.
Once set this option cannot be disabled anymore.
Sourcepub fn export_edge_weights(
self,
edge_weight: Box<dyn for<'a> Fn(&'a G::EdgeWeight) -> Vec<(Cow<'static, str>, Cow<'a, str>)>>,
) -> Self
pub fn export_edge_weights( self, edge_weight: Box<dyn for<'a> Fn(&'a G::EdgeWeight) -> Vec<(Cow<'static, str>, Cow<'a, str>)>>, ) -> Self
Export the edge weights to GraphML.
This uses a custom conversion function. Each edge can be converted into an arbitray number of attributes. Each attribute is a key-value pair, represented as tuple.
Once set this option cannot be disabled anymore.
§Example
A custom print function for the type (String, u32)
.
It will create two attributes “str attr” and “int attr” containing the string and integer part.
let graph = make_graph();
let graphml = GraphMl::new(&graph).export_edge_weights(Box::new(|edge| {
let &(ref s, i) = edge;
vec![
("str attr".into(), s[..].into()),
("int attr".into(), i.to_string().into()),
]
}));
Currently only string attribute types are supported.
Sourcepub fn export_node_weights_display(self) -> Selfwhere
G::NodeWeight: Display,
pub fn export_node_weights_display(self) -> Selfwhere
G::NodeWeight: Display,
Export the node weights to GraphML.
This uses the Display
implementation of the node weight type.
The attribute name defaults to “weight”.
Once set this option cannot be disabled anymore.
Sourcepub fn export_node_weights(
self,
node_weight: Box<dyn for<'a> Fn(&'a G::NodeWeight) -> Vec<(Cow<'static, str>, Cow<'a, str>)>>,
) -> Self
pub fn export_node_weights( self, node_weight: Box<dyn for<'a> Fn(&'a G::NodeWeight) -> Vec<(Cow<'static, str>, Cow<'a, str>)>>, ) -> Self
Export the node weights to GraphML.
This uses a custom conversion function. Each node can be converted into an arbitray number of attributes. Each attribute is a key-value pair, represented as tuple.
Once set this option cannot be disabled anymore.
§Example
A custom print function for the type (String, u32)
.
It will create two attributes “str attr” and “int attr” containing the string and integer part.
let graph = make_graph();
let graphml = GraphMl::new(&graph).export_node_weights(Box::new(|node| {
let &(ref s, i) = node;
vec![
("str attr".into(), s[..].into()),
("int attr".into(), i.to_string().into()),
]
}));
Currently only string attribute types are supported.