Skip to main content

GmlWriteOptions

Struct GmlWriteOptions 

Source
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: bool

Encode 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>

Source

pub fn with_encode_only_quot(self, only_quot: bool) -> Self

Source

pub fn with_ids(self, ids: &'a [f64]) -> Self

Sets ids.

Source

pub fn with_creator(self, creator: &'a str) -> Self

Sets creator.

Trait Implementations§

Source§

impl<'a> Clone for GmlWriteOptions<'a>

Source§

fn clone(&self) -> GmlWriteOptions<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for GmlWriteOptions<'a>

Source§

impl<'a> Debug for GmlWriteOptions<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for GmlWriteOptions<'a>

Source§

fn default() -> GmlWriteOptions<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for GmlWriteOptions<'a>

Source§

fn eq(&self, other: &GmlWriteOptions<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for GmlWriteOptions<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GmlWriteOptions<'a>

§

impl<'a> RefUnwindSafe for GmlWriteOptions<'a>

§

impl<'a> Send for GmlWriteOptions<'a>

§

impl<'a> Sync for GmlWriteOptions<'a>

§

impl<'a> Unpin for GmlWriteOptions<'a>

§

impl<'a> UnsafeUnpin for GmlWriteOptions<'a>

§

impl<'a> UnwindSafe for GmlWriteOptions<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.