pub struct GmlWriteOptions<'a> {
pub encode_only_quot: bool,
pub ids: Option<&'a [f64]>,
pub creator: Option<&'a str>,
}Expand description
Options of the GML writer (Graph::write_graph_gml).
The default writes igraph’s own vertex ids (or the numeric id vertex
attribute, if present), encodes all special characters as entities, and
writes a Creator line mentioning the igraph version and the current date
and time (use with_creator("") for reproducible
output).
§Examples
use igraph::{foreign::GmlWriteOptions, prelude::*};
let g = Graph::from_edges(&[(0, 1)], 2, true).unwrap();
let opts = GmlWriteOptions::default().with_creator("").with_ids(&[7.0, 9.0]);
let gml = g.write_graph_gml_to_string(&opts).unwrap();
let lines: Vec<&str> = gml.lines().map(str::trim).collect();
assert_eq!(
lines,
[
"Version 1", "graph", "[", "directed 1",
"node", "[", "id 7", "]",
"node", "[", "id 9", "]",
"edge", "[", "source 7", "target 9", "]",
"]",
]
);Fields§
§encode_only_quot: boolEncode only " characters as entities, nothing else
(IGRAPH_WRITE_GML_ENCODE_ONLY_QUOT_SW); useful to re-export files
whose entities igraph passed through undecoded.
ids: Option<&'a [f64]>Numeric vertex ids to write in the id fields instead of igraph’s
vertex ids (one per vertex). With None, a numeric id vertex
attribute is used if there is one (the GML reader creates it when the
attribute handler is on, so a GML round
trip keeps the original ids), otherwise igraph’s vertex ids. If some
value is not an integer (or is NaN/infinite), or some value is
repeated, igraph emits a warning (see
take_warnings) and ignores all of
them, writing its own vertex ids instead.
creator: Option<&'a str>Text of the Creator line: None writes the igraph version plus the
current date and time, Some("") omits the line, anything else is
written as a GML string, with " (and &, unless
encode_only_quot) encoded as XML entities.
Implementations§
Source§impl<'a> GmlWriteOptions<'a>
impl<'a> GmlWriteOptions<'a>
Sourcepub fn with_encode_only_quot(self, only_quot: bool) -> Self
pub fn with_encode_only_quot(self, only_quot: bool) -> Self
Sets encode_only_quot.
Sourcepub fn with_creator(self, creator: &'a str) -> Self
pub fn with_creator(self, creator: &'a str) -> Self
Sets creator.
Trait Implementations§
Source§impl<'a> Clone for GmlWriteOptions<'a>
impl<'a> Clone for GmlWriteOptions<'a>
Source§fn clone(&self) -> GmlWriteOptions<'a>
fn clone(&self) -> GmlWriteOptions<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for GmlWriteOptions<'a>
Source§impl<'a> Debug for GmlWriteOptions<'a>
impl<'a> Debug for GmlWriteOptions<'a>
Source§impl<'a> Default for GmlWriteOptions<'a>
impl<'a> Default for GmlWriteOptions<'a>
Source§fn default() -> GmlWriteOptions<'a>
fn default() -> GmlWriteOptions<'a>
Source§impl<'a> PartialEq for GmlWriteOptions<'a>
impl<'a> PartialEq for GmlWriteOptions<'a>
Source§fn eq(&self, other: &GmlWriteOptions<'a>) -> bool
fn eq(&self, other: &GmlWriteOptions<'a>) -> bool
self and other values to be equal, and is used by ==.