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

Create a new GraphML printer for the graph.

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.

Write the GraphML file to the given writer.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.