Struct petgraph_graphml::GraphMl [−][src]
pub struct GraphMl<G> where
G: IntoEdgeReferences,
G: IntoNodeReferences, { /* fields omitted */ }
Expand description
GraphML output printer
See the main crate documentation for usage instructions and examples.
Implementations
impl<G> GraphMl<G> where
G: GraphProp,
G: IntoNodeReferences,
G: IntoEdgeReferences,
G: NodeIndexable,
impl<G> GraphMl<G> where
G: GraphProp,
G: IntoNodeReferences,
G: IntoEdgeReferences,
G: NodeIndexable,
Enable or disble pretty printing of the XML.
Pretty printing enables linebreaks and indentation.
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.
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.
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.
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.