Skip to main content

AttributeRecord

Type Alias AttributeRecord 

Source
pub type AttributeRecord = igraph_attribute_record_t;
Expand description

A named, typed vector of attribute values (igraph_attribute_record_t).

Attribute records are the unit of data exchanged between igraph and an attribute handler; in Rust they are mostly useful to add vertices or edges together with their attributes, see Graph::add_vertices_with_attributes. A record owns its values and frees them on Drop; Clone makes a deep copy, default value included.

A record also has a default value, used to fill new slots when it is resized: NaN, false or "" unless changed with set_default.

use igraph::attributes::{AttributeRecord, AttributeType, AttributeValue, AttributeValues};

let mut rec = AttributeRecord::numeric("score", &[1.0, 2.0]).unwrap();
rec.set_default(AttributeValue::Numeric(-1.0)).unwrap();
rec.resize(4).unwrap();
assert_eq!(rec.name(), Some("score"));
assert_eq!(rec.attribute_type(), AttributeType::Numeric);
assert_eq!(rec.values(), AttributeValues::Numeric(vec![1.0, 2.0, -1.0, -1.0]));

Aliased Typeยง

pub struct AttributeRecord { /* private fields */ }