Skip to main content

enable

Function enable 

Source
pub fn enable() -> Result<()>
Expand description

Turns on igraph’s C attribute handler for the whole process.

This attaches igraph’s C attribute handler (igraph_cattribute_table, in a variant guarded against graphs without attribute storage) with igraph_set_attribute_table. From then on every newly created graph carries attribute storage, and igraph keeps graph, vertex and edge attributes in sync with every structural change.

  • It is idempotent (cheap after the first call) and irreversible.
  • The setting is process-wide, not per thread: call it early, ideally at the start of main, before other threads use igraph.
  • Attribute setters call it implicitly; call it explicitly before reading graphs from files whose attributes (vertex names, edge weights, …) you want to keep.
  • Graphs created before enabling keep working; they simply have no attributes until the first setter creates their storage.

§Errors

ErrorKind::Exists if a different attribute handler was attached beforehand through the raw FFI; that handler is left in place.

§Examples

use igraph::attributes;
attributes::enable().unwrap();
attributes::enable().unwrap(); // no-op
assert!(attributes::is_enabled());
assert!(attributes::has_attribute_table());