OpenBI Docs Buy

Attributes

Values kept on a graph, its vertices and its edges: the handler interface, attribute records, how values combine when vertices or edges are merged, and the built-in handler for numbers, Booleans and text.

57 entries: 52 functions and 5 types. Part of the Open Graph reference; All functions lists every entry on one page, with a filter. The badges say how each entry is checked.

Attribute handlers

attribute_table_ttype#

Unit tests

The callbacks through which an attribute handler keeps values for graphs, vertices and edges.

typedef struct og_attribute_table_t {
    og_error_t (*init)(og_t *graph, const og_attribute_record_list_t *attr);
    void (*destroy)(og_t *graph);
    og_error_t (*copy)(og_t *to, const og_t *from, og_bool_t ga, og_bool_t va, og_bool_t ea);
    og_error_t (*add_vertices)(og_t *graph, og_int_t nv, const og_attribute_record_list_t *attr);
    og_error_t (*permute_vertices)(const og_t *graph, og_t *newgraph, const og_vector_int_t *idx);
    og_error_t (*combine_vertices)(const og_t *graph, og_t *newgraph,
        const og_vector_int_list_t *merges,
        const og_attribute_combination_t *comb);
    og_error_t (*add_edges)(og_t *graph, const og_vector_int_t *edges,
        const og_attribute_record_list_t *attr);
    og_error_t (*permute_edges)(const og_t *graph, og_t *newgraph, const og_vector_int_t *idx);
    og_error_t (*combine_edges)(const og_t *graph, og_t *newgraph,
        const og_vector_int_list_t *merges,
        const og_attribute_combination_t *comb);
    og_error_t (*get_info)(const og_t *graph, og_strvector_t *gnames, og_vector_int_t *gtypes,
        og_strvector_t *vnames, og_vector_int_t *vtypes,
        og_strvector_t *enames, og_vector_int_t *etypes);
    og_bool_t (*has_attr)(const og_t *graph, og_attribute_elemtype_t type, const char *name);
    og_error_t (*get_type)(const og_t *graph, og_attribute_type_t *type,
        og_attribute_elemtype_t elemtype, const char *name);
    og_error_t (*get_numeric_graph_attr)(const og_t *graph, const char *name, og_vector_t *value);
    og_error_t (*get_string_graph_attr)(const og_t *graph, const char *name,
        og_strvector_t *value);
    og_error_t (*get_bool_graph_attr)(const og_t *graph, const char *name,
        og_vector_bool_t *value);
    og_error_t (*get_numeric_vertex_attr)(const og_t *graph, const char *name, og_vs_t vs,
        og_vector_t *value);
    og_error_t (*get_string_vertex_attr)(const og_t *graph, const char *name, og_vs_t vs,
        og_strvector_t *value);
    og_error_t (*get_bool_vertex_attr)(const og_t *graph, const char *name, og_vs_t vs,
        og_vector_bool_t *value);
    og_error_t (*get_numeric_edge_attr)(const og_t *graph, const char *name, og_es_t es,
        og_vector_t *value);
    og_error_t (*get_string_edge_attr)(const og_t *graph, const char *name, og_es_t es,
        og_strvector_t *value);
    og_error_t (*get_bool_edge_attr)(const og_t *graph, const char *name, og_es_t es,
        og_vector_bool_t *value);
} og_attribute_table_t;

A handler stores attribute values in graph->attr and keeps them in step with the graph. Open Graph's graph functions call init, destroy, copy, add_vertices, add_edges, permute_vertices and permute_edges themselves; after a deletion permute_* receives the same graph twice, with idx[new id] = old id. Operations that merge vertices or edges (contraction, simplification) call combine_vertices / combine_edges with the merge groups and an og_attribute_combination_t. File readers and writers and conversions use get_info, has_attr, get_type and the nine typed getters. Any member may be NULL: a structural step is then skipped, and a read through a missing getter fails with OG_EINVAL.

Open Graph ships one handler, og_cattribute_table (numeric, Boolean and string attributes). The members are in the same order as in igraph 1.0's C interface, so a handler written for it ports by renaming.

Parameters
  • init a graph was created; attr holds optional records with graph attributes
  • destroy the graph is being destroyed; free graph->attr
  • copy copy the graph (ga), vertex (va) and/or edge (ea) attributes of from into to
  • add_vertices nv vertices were added; attr holds optional records with their values
  • permute_vertices newgraph's vertex i takes the values of graph's vertex idx[i]
  • combine_vertices newgraph's vertex i takes the values of the group merges[i], combined by comb
  • add_edges edges were added (pairs in edges); attr holds optional records with their values
  • permute_edges newgraph's edge i takes the values of graph's edge idx[i]
  • combine_edges newgraph's edge i takes the values of the group merges[i], combined by comb
  • get_info names and types of the graph, vertex and edge attributes; outputs may be NULL
  • has_attr whether an attribute of that kind and name exists
  • get_type the attribute_type_t of an attribute
  • get_numeric_graph_attr, get_string_graph_attr, get_bool_graph_attr read a graph attribute
  • get_numeric_vertex_attr, get_string_vertex_attr, get_bool_vertex_attr read a vertex attribute for a vertex selection
  • get_numeric_edge_attr, get_string_edge_attr, get_bool_edge_attr read an edge attribute for an edge selection
Checked
no python-igraph counterpart; a recording handler checks when and with what arguments the graph functions call each member, and the C handler replays python-igraph's permutation, subgraph and conversion mappings
C name
og_attribute_table_t
In notebooks
Og.AttributeTable
igraph 1.0
igraph_attribute_table_t
See also
set_attribute_table, attribute_combination_init, attribute_record_t, attribute_type_t, attribute_elemtype_t

set_attribute_table#

Unit tests

Attaches an attribute handler for the whole process and returns the previous one.

og_attribute_table_t *og_set_attribute_table(
    const og_attribute_table_t *table
);

Graphs created after the call keep their attributes through table; graphs created while no handler was attached have no attribute storage and keep none. Pass &og_cattribute_table for the built-in handler, or NULL to detach.

The setting is process-wide and shared by all threads: attach the handler once at start-up, before any graph exists and before other threads use Open Graph.

Parameters
  • table the handler to attach, or NULL for none
Returns
The table attached before, or NULL when there was none.
Complexity
O(1)
Checked
unit tests: returns the previous table, NULL detaches, the graph functions then call the new members
C name
og_set_attribute_table
In notebooks
Og.Native.og_set_attribute_table
igraph 1.0
igraph_set_attribute_table
See also
attribute_table_t, cattribute_VAN_set, cattribute_list
og_t g;
og_set_attribute_table(&og_cattribute_table);   /* once, before any graph */
OG_CHECK(og_small(&g, 3, OG_UNDIRECTED, 0, 1, 1, 2, -1));
OG_FINALLY(og_destroy, &g);
OG_CHECK(og_cattribute_VAS_set(&g, "city", 0, "Oslo"));
OG_CHECK(og_cattribute_EAN_set(&g, "km", 1, 463.0));
printf("%s %g\n", VAS(&g, "city", 0), EAN(&g, "km", 1));   /* Oslo 463 */
/* EAN(&g, "km", 0) is NaN: edge 0 has the default value */
og_destroy(&g);
OG_FINALLY_CLEAN(1);

attribute_type_ttype#

Unit tests

The kind of value an attribute holds.

typedef enum og_attribute_type_t {
    OG_ATTRIBUTE_UNSPECIFIED = 0, /* placeholder only; never stored in a graph */
    OG_ATTRIBUTE_NUMERIC = 1,     /* og_real_t values (og_vector_t) */
    OG_ATTRIBUTE_BOOLEAN = 2,     /* og_bool_t values (og_vector_bool_t) */
    OG_ATTRIBUTE_STRING = 3,      /* strings (og_strvector_t) */
    OG_ATTRIBUTE_OBJECT = 127     /* opaque values of a foreign handler (Python, R, ...) */
} og_attribute_type_t;

OG_ATTRIBUTE_NUMERIC values are og_real_t and live in an vector_t, OG_ATTRIBUTE_BOOLEAN values are og_bool_t in an og_vector_bool_t, and OG_ATTRIBUTE_STRING values are strings in an og_strvector_t. OG_ATTRIBUTE_UNSPECIFIED is a placeholder that is never stored in a graph. OG_ATTRIBUTE_OBJECT marks opaque values of a handler written for another language; the C handler does not keep them. The numeric values (0, 1, 2, 3, 127) are those of igraph 1.0.

Checked
values fixed by the interface; unit tests
C name
og_attribute_type_t
In notebooks
Og.AttributeType
igraph 1.0
igraph_attribute_type_t
See also
attribute_record_t, attribute_elemtype_t, cattribute_list

attribute_elemtype_ttype#

Unit tests

Says whether an attribute belongs to the graph, to its vertices or to its edges.

typedef enum og_attribute_elemtype_t {
    OG_ATTRIBUTE_GRAPH = 0,
    OG_ATTRIBUTE_VERTEX,
    OG_ATTRIBUTE_EDGE
} og_attribute_elemtype_t;

OG_ATTRIBUTE_GRAPH is 0, OG_ATTRIBUTE_VERTEX 1 and OG_ATTRIBUTE_EDGE 2.

Checked
values fixed by the interface; unit tests
C name
og_attribute_elemtype_t
In notebooks
Og.AttributeElemtype
igraph 1.0
igraph_attribute_elemtype_t
See also
cattribute_has_attr, attribute_type_t

Attribute records

attribute_record_ttype#

Unit tests

A named attribute: its type, its values and a default value.

typedef struct og_attribute_record_t {
    char *name; /* may be NULL */
    og_attribute_type_t type;
    union {
        void *as_raw;
        og_vector_t *as_vector;
        og_strvector_t *as_strvector;
        og_vector_bool_t *as_vector_bool;
    } value;
    union {
        og_real_t numeric;
        og_bool_t boolean;
        char *string; /* NULL is the empty string */
    } default_value;
} og_attribute_record_t;

The record owns its name, its value container and, for strings, its default. Which member of value is in use depends on type: as_vector for numeric, as_vector_bool for Boolean, as_strvector for string; UNSPECIFIED and OBJECT records hold no container. A graph attribute has one value, a vertex or edge attribute one per element.

Records carry attribute values into empty_attrs(), add_vertices() and add_edges(), collected in an og_attribute_record_list_t, which has the full list API of the containers area (og_attribute_record_list_init, _push_back_new, ...). The default fills new slots when the record grows: NaN, false or the empty string unless set otherwise.

Parameters
  • name the attribute's name (owned; may be NULL)
  • type an attribute_type_t
  • value union of container pointers: as_vector, as_vector_bool, as_strvector, as_raw
  • default_value union: numeric, boolean, or string (owned; NULL is the empty string)
Checked
own layout; unit tests and fault-injection runs over the record functions
C name
og_attribute_record_t
In notebooks
Og.AttributeRecord
igraph 1.0
igraph_attribute_record_t
See also
attribute_record_init, attribute_record_resize, add_vertices, add_edges

attribute_record_init#

Unit tests

Sets up a record with a name, a type and no values yet.

og_error_t og_attribute_record_init(
    og_attribute_record_t *attr,
    const char *name,
    og_attribute_type_t type
);

The name is copied; NULL is allowed and "" stays "". The record starts with no values and the natural default of its type: NaN, false or the empty string. Give it values with attribute_record_resize() and the record's container. On failure the record is safe to destroy.

Parameters
  • attr the record to set up
  • name the attribute's name, or NULL
  • type the value type
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL type is not a value of attribute_type_t
  • OG_ENOMEM memory could not be allocated
Complexity
O(length of name)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_init
In notebooks
Og.Native.og_attribute_record_init
igraph 1.0
igraph_attribute_record_init
See also
attribute_record_destroy, attribute_record_resize, attribute_record_set_default_numeric, add_vertices
/* add two vertices with a string attribute "city" */
og_attribute_record_list_t recs;
og_attribute_record_t *r;
OG_ATTRIBUTE_RECORD_LIST_INIT_FINALLY(&recs, 0);
OG_CHECK(og_attribute_record_list_push_back_new(&recs, &r));
OG_CHECK(og_attribute_record_set_name(r, "city"));
OG_CHECK(og_attribute_record_set_type(r, OG_ATTRIBUTE_STRING));
OG_CHECK(og_attribute_record_resize(r, 2));
OG_CHECK(og_strvector_set(r->value.as_strvector, 0, "Oslo"));
OG_CHECK(og_strvector_set(r->value.as_strvector, 1, "Bergen"));
OG_CHECK(og_add_vertices(&g, 2, &recs));
og_attribute_record_list_destroy(&recs);
OG_FINALLY_CLEAN(1);

attribute_record_init_copy#

Unit tests

Creates a deep copy of an attribute record.

og_error_t og_attribute_record_init_copy(
    og_attribute_record_t *to,
    const og_attribute_record_t *from
);

Name, type, values and default are all copied; the two records share nothing. On failure to is safe to destroy.

Parameters
  • to the record to set up
  • from the record to copy
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_ENOMEM memory could not be allocated
Complexity
O(number of values + length of the strings)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_init_copy
In notebooks
Og.Native.og_attribute_record_init_copy
igraph 1.0
igraph_attribute_record_init_copy
See also
attribute_record_init, attribute_record_destroy

attribute_record_size#

Unit tests

Returns the number of values in an attribute record.

og_int_t og_attribute_record_size(const og_attribute_record_t *attr);

0 for UNSPECIFIED and OBJECT records, which hold no values.

Parameters
  • attr the record
Returns
The number of values.
Complexity
O(1)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_size
In notebooks
Og.Native.og_attribute_record_size
igraph 1.0
igraph_attribute_record_size
See also
attribute_record_resize

attribute_record_resize#

Unit tests

Changes the number of values of a record, filling new slots with its default.

og_error_t og_attribute_record_resize(
    og_attribute_record_t *attr,
    og_int_t new_size
);

Shrinking drops values at the end. If copying the string default into new slots fails, the record is left as it was.

Parameters
  • attr the record
  • new_size new number of values, zero or more
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL new_size is negative
  • OG_EINVAL the record is of UNSPECIFIED or OBJECT type
  • OG_ENOMEM memory could not be allocated
Complexity
O(|new_size - size|), times the default's length for strings
Checked
unit tests, including out-of-memory runs; fault injection over 300 random operation sequences
C name
og_attribute_record_resize
In notebooks
Og.Native.og_attribute_record_resize
igraph 1.0
igraph_attribute_record_resize
See also
attribute_record_size, attribute_record_set_default_numeric, attribute_record_set_default_string, attribute_record_set_default_boolean

attribute_record_set_name#

Unit tests

Renames an attribute record.

og_error_t og_attribute_record_set_name(
    og_attribute_record_t *attr,
    const char *name
);

The new name is copied before the old one is freed, so on failure the record keeps its name. NULL is allowed.

Parameters
  • attr the record
  • name the new name, or NULL
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_ENOMEM memory could not be allocated
Complexity
O(length of name)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_set_name
In notebooks
Og.Native.og_attribute_record_set_name
igraph 1.0
igraph_attribute_record_set_name
See also
attribute_record_init

attribute_record_set_type#

Unit tests

Changes the type of a record, dropping its values.

og_error_t og_attribute_record_set_type(
    og_attribute_record_t *attr,
    og_attribute_type_t type
);

Setting the current type does nothing. Any other type replaces the values with an empty container of the new type and resets the default to that type's natural one. On failure the record is unchanged.

Parameters
  • attr the record
  • type the new value type
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL type is not a value of attribute_type_t
  • OG_ENOMEM memory could not be allocated
Complexity
O(number of values dropped)
Checked
unit tests, including out-of-memory runs; fault injection over 300 random operation sequences
C name
og_attribute_record_set_type
In notebooks
Og.Native.og_attribute_record_set_type
igraph 1.0
igraph_attribute_record_set_type
See also
attribute_record_init, attribute_record_resize

attribute_record_set_default_numeric#

Unit tests

Sets the value that new slots of a numeric record receive.

og_error_t og_attribute_record_set_default_numeric(
    og_attribute_record_t *attr,
    og_real_t value
);

Values already in the record are not touched. The default fills the slots added by later attribute_record_resize() calls and, when the record creates a new attribute through add_vertices() or add_edges() (C handler), the values of the elements that were there before.

Parameters
  • attr a numeric record
  • value the new default
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the record is not numeric
Complexity
O(1)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_set_default_numeric
In notebooks
Og.Native.og_attribute_record_set_default_numeric
igraph 1.0
igraph_attribute_record_set_default_numeric
See also
attribute_record_resize, attribute_record_set_default_string, attribute_record_set_default_boolean

attribute_record_set_default_string#

Unit tests

Sets the string that new slots of a string record receive.

og_error_t og_attribute_record_set_default_string(
    og_attribute_record_t *attr,
    const char *value
);

The string is copied; NULL means the empty string. Values already in the record are not touched. The default fills the slots added by later attribute_record_resize() calls and, when the record creates a new attribute through add_vertices() or add_edges() (C handler), the values of the elements that were there before.

Parameters
  • attr a string record
  • value the new default, or NULL
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the record is not a string record
  • OG_ENOMEM memory could not be allocated
Complexity
O(length of value)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_set_default_string
In notebooks
Og.Native.og_attribute_record_set_default_string
igraph 1.0
igraph_attribute_record_set_default_string
See also
attribute_record_resize, attribute_record_set_default_numeric, attribute_record_set_default_boolean

attribute_record_set_default_boolean#

Unit tests

Sets the value that new slots of a Boolean record receive.

og_error_t og_attribute_record_set_default_boolean(
    og_attribute_record_t *attr,
    og_bool_t value
);

Values already in the record are not touched. The default fills the slots added by later attribute_record_resize() calls and, when the record creates a new attribute through add_vertices() or add_edges() (C handler), the values of the elements that were there before.

Parameters
  • attr a Boolean record
  • value the new default
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the record is not Boolean
Complexity
O(1)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_set_default_boolean
In notebooks
Og.Native.og_attribute_record_set_default_boolean
igraph 1.0
igraph_attribute_record_set_default_boolean
See also
attribute_record_resize, attribute_record_set_default_numeric, attribute_record_set_default_string

attribute_record_destroy#

Unit tests

Releases everything an attribute record owns: name, values and default.

void og_attribute_record_destroy(og_attribute_record_t *attr);

Safe to call twice; NULL is accepted. Afterwards the record is an unnamed UNSPECIFIED record with no values.

Parameters
  • attr the record
Returns
Nothing.
Complexity
O(number of values)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_record_destroy
In notebooks
Og.Native.og_attribute_record_destroy
igraph 1.0
igraph_attribute_record_destroy
See also
attribute_record_init

Combining values

attribute_combination_init#

Exact

Creates an empty list of combination rules.

og_error_t og_attribute_combination_init(og_attribute_combination_t *comb);

With an empty list every attribute is dropped when vertices or edges are merged. Add rules with attribute_combination_add(). Nothing is allocated until the first rule, so this call cannot fail.

Parameters
  • comb the list to set up
Returns
OG_SUCCESS.
Complexity
O(1)
Checked
whole rule lists (a default rule given as NULL or "", rules of their own, ignores, names the graph lacks) resolve as python-igraph 1.0's contract_vertices and simplify do: same attributes kept, same order, same values, 260 lists per kind
C name
og_attribute_combination_init
In notebooks
Og.Native.og_attribute_combination_init
igraph 1.0
igraph_attribute_combination_init
See also
attribute_combination_add, attribute_combination, attribute_combination_destroy

attribute_combination_add#

Exact

Adds a rule saying how one attribute, or every other attribute, is combined.

og_error_t og_attribute_combination_add(
    og_attribute_combination_t *comb,
    const char *name,
    og_attribute_combination_type_t type,
    og_function_pointer_t func
);

name NULL or "" sets the default rule, which applies to every attribute without a rule of its own. A rule for a name that already has one replaces it. func is used only with OG_ATTRIBUTE_COMBINE_FUNCTION and must then be non-NULL; its real signature depends on the attribute's type (see attribute_combination_type_t) and it is passed cast to og_function_pointer_t.

Parameters
  • comb the list
  • name attribute name; NULL or "" for the default rule
  • type how the values are combined
  • func the function for OG_ATTRIBUTE_COMBINE_FUNCTION, else ignored
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL type is not a value of attribute_combination_type_t
  • OG_EINVAL type is OG_ATTRIBUTE_COMBINE_FUNCTION and func is NULL
  • OG_ENOMEM memory could not be allocated
Complexity
O(r) for r rules in the list
Checked
whole rule lists (a default rule given as NULL or "", rules of their own, ignores, names the graph lacks) resolve as python-igraph 1.0's contract_vertices and simplify do: same attributes kept, same order, same values, 260 lists per kind
C name
og_attribute_combination_add
In notebooks
Og.Native.og_attribute_combination_add
igraph 1.0
igraph_attribute_combination_add
See also
attribute_combination_remove, attribute_combination, attribute_combination_type_t

attribute_combination_remove#

Unit tests

Removes the rule for a name from a combination list.

og_error_t og_attribute_combination_remove(
    og_attribute_combination_t *comb,
    const char *name
);

NULL or "" removes the default rule. A name without a rule is ignored; the call always succeeds.

Parameters
  • comb the list
  • name attribute name; NULL or "" for the default rule
Returns
OG_SUCCESS.
Complexity
O(r) for r rules
Checked
unit tests
C name
og_attribute_combination_remove
In notebooks
Og.Native.og_attribute_combination_remove
igraph 1.0
igraph_attribute_combination_remove
See also
attribute_combination_add

attribute_combination_destroy#

Unit tests

Frees a list of combination rules.

void og_attribute_combination_destroy(og_attribute_combination_t *comb);

Safe to call twice; NULL is accepted.

Parameters
  • comb the list
Returns
Nothing.
Complexity
O(r) for r rules
Checked
unit tests
C name
og_attribute_combination_destroy
In notebooks
Og.Native.og_attribute_combination_destroy
igraph 1.0
igraph_attribute_combination_destroy
See also
attribute_combination_init, attribute_combination

attribute_combination_type_ttype#

Exact

How the values of merged vertices or edges are turned into one value.

typedef enum og_attribute_combination_type_t {
    OG_ATTRIBUTE_COMBINE_IGNORE = 0,   /* drop the attribute */
    OG_ATTRIBUTE_COMBINE_DEFAULT = 1,  /* the handler decides (the C handler: drop) */
    OG_ATTRIBUTE_COMBINE_FUNCTION = 2, /* a user function */
    OG_ATTRIBUTE_COMBINE_SUM = 3,
    OG_ATTRIBUTE_COMBINE_PROD = 4,
    OG_ATTRIBUTE_COMBINE_MIN = 5,
    OG_ATTRIBUTE_COMBINE_MAX = 6,
    OG_ATTRIBUTE_COMBINE_RANDOM = 7,
    OG_ATTRIBUTE_COMBINE_FIRST = 8,
    OG_ATTRIBUTE_COMBINE_LAST = 9,
    OG_ATTRIBUTE_COMBINE_MEAN = 10,
    OG_ATTRIBUTE_COMBINE_MEDIAN = 11,
    OG_ATTRIBUTE_COMBINE_CONCAT = 12
} og_attribute_combination_type_t;

IGNORE drops the attribute; DEFAULT lets the handler decide (the C handler drops it); FUNCTION calls a function of the caller; SUM, PROD, MIN, MAX, RANDOM, FIRST, LAST, MEAN, MEDIAN and CONCAT are built in. The C handler takes the values in the order of the merge group.

Numeric: SUM (0 for an empty group), PROD (1 for an empty group), MIN, MAX and MEDIAN (NaN when any value is NaN; an even group's median is the mean of the two middle values), MEAN, FIRST, LAST, RANDOM; the others give NaN for an empty group; CONCAT is OG_EATTRCOMBINE. Boolean: SUM and MAX mean any, PROD and MIN mean all (PROD of an empty group is true), MEAN and MEDIAN mean more than half true, FIRST, LAST, RANDOM; an empty group gives false otherwise; CONCAT is OG_EATTRCOMBINE. String: FIRST, LAST, RANDOM, CONCAT (joined without separator), MIN and MAX (byte order, which is code point order for UTF-8); an empty group gives ""; SUM, PROD, MEAN and MEDIAN are OG_EATTRCOMBINE.

A FUNCTION rule's function has one of these forms, cast to og_function_pointer_t: error_t f(const vector_t *in, og_real_t *out); error_t f(const og_vector_bool_t *in, og_bool_t *out); error_t f(const og_strvector_t *in, char **out), where the string is copied and stays the function's, and NULL means "". RANDOM draws from the calling thread's default random generator.

Checked
numeric SUM/PROD/MIN/MAX/MEAN/MEDIAN/FIRST/LAST and string FIRST/LAST/CONCAT/MIN/MAX identical to python-igraph 1.0's contract_vertices and simplify (240 merge lists, vertex and edge paths); Boolean rules give its truth values on non-empty groups (57,968 merged values); RANDOM passes chi-square and serial tests; the mean of an empty group differs on purpose (NaN here, 0 in python-igraph)
C name
og_attribute_combination_type_t
In notebooks
Og.AttributeCombinationType
igraph 1.0
igraph_attribute_combination_type_t
See also
attribute_combination_add, attribute_combination, simplify, contract_vertices

attribute_combination#

Unit tests

Creates a list of combination rules from a variable argument list.

og_error_t og_attribute_combination(og_attribute_combination_t *comb, ...);

Arguments come in groups: a name (const char *, NULL for the default rule), a type (attribute_combination_type_t) and, only when the type is OG_ATTRIBUTE_COMBINE_FUNCTION, the function. OG_NO_MORE_ATTRIBUTES ends the list; it is distinct from NULL, which names the default rule. The rules are added in order with attribute_combination_add(), so a later rule for the same name wins. On error comb is left destroyed.

Parameters
  • comb the list to set up
  • ... name, type[, func] groups, ended by OG_NO_MORE_ATTRIBUTES
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL a type is out of range, or a FUNCTION rule has no function
  • OG_ENOMEM memory could not be allocated
Complexity
O(r^2) for r rules (each add searches the list)
Checked
unit tests, including out-of-memory runs
C name
og_attribute_combination
igraph 1.0
igraph_attribute_combination
See also
attribute_combination_add, attribute_combination_destroy, attribute_combination_type_t
og_attribute_combination_t comb;
OG_CHECK(og_attribute_combination(&comb,
    "weight", OG_ATTRIBUTE_COMBINE_SUM,
    "label",  OG_ATTRIBUTE_COMBINE_FIRST,
    NULL,     OG_ATTRIBUTE_COMBINE_IGNORE,     /* every other attribute */
    OG_NO_MORE_ATTRIBUTES));
OG_FINALLY(og_attribute_combination_destroy, &comb);
OG_CHECK(og_simplify(&g, true, true, &comb));    /* parallel edges: weights added */
og_attribute_combination_destroy(&comb);
OG_FINALLY_CLEAN(1);

The built-in handler: reading

cattribute_list#

Exact

Lists the names and types of a graph's attributes.

og_error_t og_cattribute_list(
    const og_t *graph,
    og_strvector_t *gnames,
    og_vector_int_t *gtypes,
    og_strvector_t *vnames,
    og_vector_int_t *vtypes,
    og_strvector_t *enames,
    og_vector_int_t *etypes
);

Fills, separately for graph, vertex and edge attributes, a string vector of names and an integer vector of attribute_type_t values, in the order the attributes were created; entry k of a name vector belongs with entry k of its type vector. Any output may be NULL to skip it. A graph without C-handler storage reports no attributes.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • gnames receives the graph attribute names; may be NULL
  • gtypes receives their types; may be NULL
  • vnames receives the vertex attribute names; may be NULL
  • vtypes receives their types; may be NULL
  • enames receives the edge attribute names; may be NULL
  • etypes receives their types; may be NULL
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_ENOMEM memory could not be allocated
Complexity
O(number of attributes + total length of the names)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_list
In notebooks
Og.Native.og_cattribute_list
igraph 1.0
igraph_cattribute_list
See also
cattribute_has_attr, attribute_type_t

cattribute_has_attr#

Exact

Tells whether a graph has an attribute of a given kind and name.

og_bool_t og_cattribute_has_attr(
    const og_t *graph,
    og_attribute_elemtype_t type,
    const char *name
);

Names are compared byte for byte (case matters). The answer is false for a graph without C-handler storage and for a kind other than OG_ATTRIBUTE_GRAPH, _VERTEX or _EDGE.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • type OG_ATTRIBUTE_GRAPH, OG_ATTRIBUTE_VERTEX or OG_ATTRIBUTE_EDGE
  • name attribute name
Returns
true when the attribute exists.
Complexity
O(A) for A attributes of that kind (names are searched in order)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_has_attr
In notebooks
Og.Native.og_cattribute_has_attr
igraph 1.0
igraph_cattribute_has_attr
See also
cattribute_list

cattribute_GAN#

Exact

Returns the value of a numeric attribute of the graph.

og_real_t og_cattribute_GAN(const og_t *graph, const char *name);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not numeric gives a warning and NaN. Shorthand: OG_GAN(graph, name), and GAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
The value, or NaN after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_GAN
In notebooks
Og.Native.og_cattribute_GAN
igraph 1.0
igraph_cattribute_GAN
See also
cattribute_GAN_set, cattribute_has_attr

cattribute_GAB#

Exact

Returns the value of a Boolean attribute of the graph.

og_bool_t og_cattribute_GAB(const og_t *graph, const char *name);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not Boolean gives a warning and false. Shorthand: OG_GAB(graph, name), and GAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
The value, or false after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_GAB
In notebooks
Og.Native.og_cattribute_GAB
igraph 1.0
igraph_cattribute_GAB
See also
cattribute_GAB_set, cattribute_has_attr

cattribute_GAS#

Exact

Returns the value of a string attribute of the graph.

const char *og_cattribute_GAS(const og_t *graph, const char *name);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not string gives a warning and "". The pointer refers to the graph's own storage: do not free it; it stays valid until the attribute is changed or removed or the graph destroyed. Shorthand: OG_GAS(graph, name), and GAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
The value, or "" after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_GAS
In notebooks
Og.Native.og_cattribute_GAS
igraph 1.0
igraph_cattribute_GAS
See also
cattribute_GAS_set, cattribute_has_attr

cattribute_VAN#

Exact

Returns the numeric value one vertex has for an attribute.

og_real_t og_cattribute_VAN(
    const og_t *graph,
    const char *name,
    og_int_t vid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not numeric gives a warning and NaN, and so does a vertex id outside the graph. Shorthand: OG_VAN(graph, name, vid), and VAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vid vertex id
Returns
The value, or NaN after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_VAN
In notebooks
Og.Native.og_cattribute_VAN
igraph 1.0
igraph_cattribute_VAN
See also
cattribute_VAN_set, cattribute_VANV, cattribute_has_attr

cattribute_VANV#

Unit tests

Copies the numeric values of an attribute for selected vertices into a vector.

og_error_t og_cattribute_VANV(
    const og_t *graph,
    const char *name,
    og_vs_t vids,
    og_vector_t *result
);

result is resized to the number of selected vertices and filled in the order the selector gives; vss_all() selects every vertex in id order, which is what the shorthand OG_VANV(graph, name, result) (and VANV) uses. Unlike the single-value readers, problems are errors here.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vids the vertices to read
  • result receives the values (vector_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no vertex attribute of that name, or it is not numeric
  • OG_EINVVID the selector names a vertex the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected vertices
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_VANV
In notebooks
Og.Native.og_cattribute_VANV
igraph 1.0
igraph_cattribute_VANV
See also
cattribute_VAN, cattribute_VAN_setv

cattribute_VAB#

Exact

Returns the Boolean value one vertex has for an attribute.

og_bool_t og_cattribute_VAB(
    const og_t *graph,
    const char *name,
    og_int_t vid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not Boolean gives a warning and false, and so does a vertex id outside the graph. Shorthand: OG_VAB(graph, name, vid), and VAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vid vertex id
Returns
The value, or false after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_VAB
In notebooks
Og.Native.og_cattribute_VAB
igraph 1.0
igraph_cattribute_VAB
See also
cattribute_VAB_set, cattribute_VABV, cattribute_has_attr

cattribute_VABV#

Unit tests

Copies the Boolean values of an attribute for selected vertices into a vector.

og_error_t og_cattribute_VABV(
    const og_t *graph,
    const char *name,
    og_vs_t vids,
    og_vector_bool_t *result
);

result is resized to the number of selected vertices and filled in the order the selector gives; vss_all() selects every vertex in id order, which is what the shorthand OG_VABV(graph, name, result) (and VABV) uses. Unlike the single-value readers, problems are errors here.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vids the vertices to read
  • result receives the values (og_vector_bool_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no vertex attribute of that name, or it is not Boolean
  • OG_EINVVID the selector names a vertex the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected vertices
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_VABV
In notebooks
Og.Native.og_cattribute_VABV
igraph 1.0
igraph_cattribute_VABV
See also
cattribute_VAB, cattribute_VAB_setv

cattribute_VAS#

Exact

Returns the string value one vertex has for an attribute.

const char *og_cattribute_VAS(
    const og_t *graph,
    const char *name,
    og_int_t vid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not string gives a warning and "", and so does a vertex id outside the graph. The pointer refers to the graph's own storage: do not free it; it stays valid until the attribute is changed or removed or the graph destroyed. Shorthand: OG_VAS(graph, name, vid), and VAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vid vertex id
Returns
The value, or "" after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_VAS
In notebooks
Og.Native.og_cattribute_VAS
igraph 1.0
igraph_cattribute_VAS
See also
cattribute_VAS_set, cattribute_VASV, cattribute_has_attr

cattribute_VASV#

Unit tests

Copies the string values of an attribute for selected vertices into a vector.

og_error_t og_cattribute_VASV(
    const og_t *graph,
    const char *name,
    og_vs_t vids,
    og_strvector_t *result
);

result is resized to the number of selected vertices and filled in the order the selector gives; vss_all() selects every vertex in id order, which is what the shorthand OG_VASV(graph, name, result) (and VASV) uses. Unlike the single-value readers, problems are errors here. The strings are copied into result; result is built aside, so on failure it is unchanged.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • vids the vertices to read
  • result receives the values (og_strvector_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no vertex attribute of that name, or it is not string
  • OG_EINVVID the selector names a vertex the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected vertices
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_VASV
In notebooks
Og.Native.og_cattribute_VASV
igraph 1.0
igraph_cattribute_VASV
See also
cattribute_VAS, cattribute_VAS_setv

cattribute_EAN#

Exact

Returns the numeric value one edge has for an attribute.

og_real_t og_cattribute_EAN(
    const og_t *graph,
    const char *name,
    og_int_t eid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not numeric gives a warning and NaN, and so does an edge id outside the graph. Shorthand: OG_EAN(graph, name, eid), and EAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eid edge id
Returns
The value, or NaN after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_EAN
In notebooks
Og.Native.og_cattribute_EAN
igraph 1.0
igraph_cattribute_EAN
See also
cattribute_EAN_set, cattribute_EANV, cattribute_has_attr

cattribute_EANV#

Unit tests

Copies the numeric values of an attribute for selected edges into a vector.

og_error_t og_cattribute_EANV(
    const og_t *graph,
    const char *name,
    og_es_t eids,
    og_vector_t *result
);

result is resized to the number of selected edges and filled in the order the selector gives; ess_all(OG_EDGEORDER_ID) selects every edge in id order, which is what the shorthand OG_EANV(graph, name, result) (and EANV) uses. Unlike the single-value readers, problems are errors here.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eids the edges to read
  • result receives the values (vector_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no edge attribute of that name, or it is not numeric
  • OG_EINVEID the selector names an edge the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected edges
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_EANV
In notebooks
Og.Native.og_cattribute_EANV
igraph 1.0
igraph_cattribute_EANV
See also
cattribute_EAN, cattribute_EAN_setv

cattribute_EAB#

Exact

Returns the Boolean value one edge has for an attribute.

og_bool_t og_cattribute_EAB(
    const og_t *graph,
    const char *name,
    og_int_t eid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not Boolean gives a warning and false, and so does an edge id outside the graph. Shorthand: OG_EAB(graph, name, eid), and EAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eid edge id
Returns
The value, or false after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_EAB
In notebooks
Og.Native.og_cattribute_EAB
igraph 1.0
igraph_cattribute_EAB
See also
cattribute_EAB_set, cattribute_EABV, cattribute_has_attr

cattribute_EABV#

Unit tests

Copies the Boolean values of an attribute for selected edges into a vector.

og_error_t og_cattribute_EABV(
    const og_t *graph,
    const char *name,
    og_es_t eids,
    og_vector_bool_t *result
);

result is resized to the number of selected edges and filled in the order the selector gives; ess_all(OG_EDGEORDER_ID) selects every edge in id order, which is what the shorthand OG_EABV(graph, name, result) (and EABV) uses. Unlike the single-value readers, problems are errors here.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eids the edges to read
  • result receives the values (og_vector_bool_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no edge attribute of that name, or it is not Boolean
  • OG_EINVEID the selector names an edge the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected edges
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_EABV
In notebooks
Og.Native.og_cattribute_EABV
igraph 1.0
igraph_cattribute_EABV
See also
cattribute_EAB, cattribute_EAB_setv

cattribute_EAS#

Exact

Returns the string value one edge has for an attribute.

const char *og_cattribute_EAS(
    const og_t *graph,
    const char *name,
    og_int_t eid
);

Returns the value directly, so problems are reported as warnings: an attribute that is missing or not string gives a warning and "", and so does an edge id outside the graph. The pointer refers to the graph's own storage: do not free it; it stays valid until the attribute is changed or removed or the graph destroyed. Shorthand: OG_EAS(graph, name, eid), and EAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eid edge id
Returns
The value, or "" after a warning.
Complexity
O(A) to find the attribute by name (A attributes of that kind), O(1) for the value
Checked
values identical to python-igraph 1.0's after delete_vertices / delete_edges on 220 random graphs and add_vertices / add_edges with attributes on 200
C name
og_cattribute_EAS
In notebooks
Og.Native.og_cattribute_EAS
igraph 1.0
igraph_cattribute_EAS
See also
cattribute_EAS_set, cattribute_EASV, cattribute_has_attr

cattribute_EASV#

Unit tests

Copies the string values of an attribute for selected edges into a vector.

og_error_t og_cattribute_EASV(
    const og_t *graph,
    const char *name,
    og_es_t eids,
    og_strvector_t *result
);

result is resized to the number of selected edges and filled in the order the selector gives; ess_all(OG_EDGEORDER_ID) selects every edge in id order, which is what the shorthand OG_EASV(graph, name, result) (and EASV) uses. Unlike the single-value readers, problems are errors here. The strings are copied into result; result is built aside, so on failure it is unchanged.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
  • eids the edges to read
  • result receives the values (og_strvector_t)
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the graph has no edge attribute of that name, or it is not string
  • OG_EINVEID the selector names an edge the graph does not have
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + k) for A attributes and k selected edges
Checked
unit tests: selector order, missing attribute, wrong type, invalid ids, the shorthand macros
C name
og_cattribute_EASV
In notebooks
Og.Native.og_cattribute_EASV
igraph 1.0
igraph_cattribute_EASV
See also
cattribute_EAS, cattribute_EAS_setv

The built-in handler: writing and removing

cattribute_GAN_set#

Exact

Stores a numeric value as a graph attribute, creating it when missing.

og_error_t og_cattribute_GAN_set(
    og_t *graph,
    const char *name,
    og_real_t value
);

If the graph has no graph attribute of that name, a numeric one is created. If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETGAN(graph, name, value), and SETGAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than numeric
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for A graph attributes
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_GAN_set
In notebooks
Og.Native.og_cattribute_GAN_set
igraph 1.0
igraph_cattribute_GAN_set
See also
cattribute_GAN, cattribute_remove_g

cattribute_GAB_set#

Exact

Stores a Boolean value as a graph attribute, creating it when missing.

og_error_t og_cattribute_GAB_set(
    og_t *graph,
    const char *name,
    og_bool_t value
);

If the graph has no graph attribute of that name, a Boolean one is created. If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETGAB(graph, name, value), and SETGAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than Boolean
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for A graph attributes
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_GAB_set
In notebooks
Og.Native.og_cattribute_GAB_set
igraph 1.0
igraph_cattribute_GAB_set
See also
cattribute_GAB, cattribute_remove_g

cattribute_GAS_set#

Exact

Stores a string value as a graph attribute, creating it when missing.

og_error_t og_cattribute_GAS_set(
    og_t *graph,
    const char *name,
    const char *value
);

If the graph has no graph attribute of that name, a string one is created. If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. The string is copied; NULL stores the empty string. Shorthand: OG_SETGAS(graph, name, value), and SETGAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than string
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for A graph attributes
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_GAS_set
In notebooks
Og.Native.og_cattribute_GAS_set
igraph 1.0
igraph_cattribute_GAS_set
See also
cattribute_GAS, cattribute_remove_g

cattribute_VAN_set#

Exact

Stores a numeric value for one vertex, creating the attribute when missing.

og_error_t og_cattribute_VAN_set(
    og_t *graph,
    const char *name,
    og_int_t vid,
    og_real_t value
);

If the graph has no vertex attribute of that name, a numeric one is created and every other vertex gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETVAN(graph, name, vid, value), and SETVAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • vid vertex id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than numeric
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVVID vid is not a vertex of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |V|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_VAN_set
In notebooks
Og.Native.og_cattribute_VAN_set
igraph 1.0
igraph_cattribute_VAN_set
See also
cattribute_VAN, cattribute_VAN_setv, cattribute_remove_v

cattribute_VAB_set#

Exact

Stores a Boolean value for one vertex, creating the attribute when missing.

og_error_t og_cattribute_VAB_set(
    og_t *graph,
    const char *name,
    og_int_t vid,
    og_bool_t value
);

If the graph has no vertex attribute of that name, a Boolean one is created and every other vertex gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETVAB(graph, name, vid, value), and SETVAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • vid vertex id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than Boolean
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVVID vid is not a vertex of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |V|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_VAB_set
In notebooks
Og.Native.og_cattribute_VAB_set
igraph 1.0
igraph_cattribute_VAB_set
See also
cattribute_VAB, cattribute_VAB_setv, cattribute_remove_v

cattribute_VAS_set#

Exact

Stores a string value for one vertex, creating the attribute when missing.

og_error_t og_cattribute_VAS_set(
    og_t *graph,
    const char *name,
    og_int_t vid,
    const char *value
);

If the graph has no vertex attribute of that name, a string one is created and every other vertex gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. The string is copied; NULL stores the empty string. Shorthand: OG_SETVAS(graph, name, vid, value), and SETVAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • vid vertex id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than string
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVVID vid is not a vertex of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |V|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_VAS_set
In notebooks
Og.Native.og_cattribute_VAS_set
igraph 1.0
igraph_cattribute_VAS_set
See also
cattribute_VAS, cattribute_VAS_setv, cattribute_remove_v

cattribute_EAN_set#

Exact

Stores a numeric value for one edge, creating the attribute when missing.

og_error_t og_cattribute_EAN_set(
    og_t *graph,
    const char *name,
    og_int_t eid,
    og_real_t value
);

If the graph has no edge attribute of that name, a numeric one is created and every other edge gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETEAN(graph, name, eid, value), and SETEAN(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • eid edge id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than numeric
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVEID eid is not an edge of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |E|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_EAN_set
In notebooks
Og.Native.og_cattribute_EAN_set
igraph 1.0
igraph_cattribute_EAN_set
See also
cattribute_EAN, cattribute_EAN_setv, cattribute_remove_e

cattribute_EAB_set#

Exact

Stores a Boolean value for one edge, creating the attribute when missing.

og_error_t og_cattribute_EAB_set(
    og_t *graph,
    const char *name,
    og_int_t eid,
    og_bool_t value
);

If the graph has no edge attribute of that name, a Boolean one is created and every other edge gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. Shorthand: OG_SETEAB(graph, name, eid, value), and SETEAB(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • eid edge id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than Boolean
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVEID eid is not an edge of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |E|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_EAB_set
In notebooks
Og.Native.og_cattribute_EAB_set
igraph 1.0
igraph_cattribute_EAB_set
See also
cattribute_EAB, cattribute_EAB_setv, cattribute_remove_e

cattribute_EAS_set#

Exact

Stores a string value for one edge, creating the attribute when missing.

og_error_t og_cattribute_EAS_set(
    og_t *graph,
    const char *name,
    og_int_t eid,
    const char *value
);

If the graph has no edge attribute of that name, a string one is created and every other edge gets the default value (NaN, false or the empty string by type). If it has one of another type, the call fails and nothing changes. If memory runs out, the graph is unchanged. The string is copied; NULL stores the empty string. Shorthand: OG_SETEAS(graph, name, eid, value), and SETEAS(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • eid edge id
  • value the value to store
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL name is NULL or empty
  • OG_EINVAL the attribute exists with a type other than string
  • OG_EINVAL the graph has no C-handler storage (it was created before the handler was attached)
  • OG_EINVEID eid is not an edge of the graph
  • OG_ENOMEM memory could not be allocated
Complexity
O(A) for an existing attribute; O(A + |E|) when it is created
Checked
identical to python-igraph 1.0 in 300 random operation sequences; fault injection shows a failed call changes nothing
C name
og_cattribute_EAS_set
In notebooks
Og.Native.og_cattribute_EAS_set
igraph 1.0
igraph_cattribute_EAS_set
See also
cattribute_EAS, cattribute_EAS_setv, cattribute_remove_e

cattribute_VAN_setv#

Exact

Fills the numeric attribute of every vertex from a vector, one value each.

og_error_t og_cattribute_VAN_setv(
    og_t *graph,
    const char *name,
    const og_vector_t *v
);

The vector must hold exactly one value per vertex, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. Shorthand: OG_SETVANV(graph, name, values), and SETVANV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • v the values (vector_t), one per vertex
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of vertices
  • OG_EINVAL the attribute exists with a type other than numeric
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |V|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_VAN_setv
In notebooks
Og.Native.og_cattribute_VAN_setv
igraph 1.0
igraph_cattribute_VAN_setv
See also
cattribute_VAN_set, cattribute_VANV

cattribute_VAB_setv#

Exact

Fills the Boolean attribute of every vertex from a vector, one value each.

og_error_t og_cattribute_VAB_setv(
    og_t *graph,
    const char *name,
    const og_vector_bool_t *v
);

The vector must hold exactly one value per vertex, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. Shorthand: OG_SETVABV(graph, name, values), and SETVABV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • v the values (og_vector_bool_t), one per vertex
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of vertices
  • OG_EINVAL the attribute exists with a type other than Boolean
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |V|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_VAB_setv
In notebooks
Og.Native.og_cattribute_VAB_setv
igraph 1.0
igraph_cattribute_VAB_setv
See also
cattribute_VAB_set, cattribute_VABV

cattribute_VAS_setv#

Exact

Fills the string attribute of every vertex from a vector, one value each.

og_error_t og_cattribute_VAS_setv(
    og_t *graph,
    const char *name,
    const og_strvector_t *sv
);

The vector must hold exactly one value per vertex, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. The strings are copied. Shorthand: OG_SETVASV(graph, name, values), and SETVASV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • sv the values (og_strvector_t), one per vertex
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of vertices
  • OG_EINVAL the attribute exists with a type other than string
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |V|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_VAS_setv
In notebooks
Og.Native.og_cattribute_VAS_setv
igraph 1.0
igraph_cattribute_VAS_setv
See also
cattribute_VAS_set, cattribute_VASV

cattribute_EAN_setv#

Exact

Fills the numeric attribute of every edge from a vector, one value each.

og_error_t og_cattribute_EAN_setv(
    og_t *graph,
    const char *name,
    const og_vector_t *v
);

The vector must hold exactly one value per edge, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. Shorthand: OG_SETEANV(graph, name, values), and SETEANV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • v the values (vector_t), one per edge
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of edges
  • OG_EINVAL the attribute exists with a type other than numeric
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |E|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_EAN_setv
In notebooks
Og.Native.og_cattribute_EAN_setv
igraph 1.0
igraph_cattribute_EAN_setv
See also
cattribute_EAN_set, cattribute_EANV

cattribute_EAB_setv#

Exact

Fills the Boolean attribute of every edge from a vector, one value each.

og_error_t og_cattribute_EAB_setv(
    og_t *graph,
    const char *name,
    const og_vector_bool_t *v
);

The vector must hold exactly one value per edge, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. Shorthand: OG_SETEABV(graph, name, values), and SETEABV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • v the values (og_vector_bool_t), one per edge
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of edges
  • OG_EINVAL the attribute exists with a type other than Boolean
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |E|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_EAB_setv
In notebooks
Og.Native.og_cattribute_EAB_setv
igraph 1.0
igraph_cattribute_EAB_setv
See also
cattribute_EAB_set, cattribute_EABV

cattribute_EAS_setv#

Exact

Fills the string attribute of every edge from a vector, one value each.

og_error_t og_cattribute_EAS_setv(
    og_t *graph,
    const char *name,
    const og_strvector_t *sv
);

The vector must hold exactly one value per edge, in id order. The attribute is created if it is missing; one of another type is an error. The values are copied first and the attribute replaced only on success. The strings are copied. Shorthand: OG_SETEASV(graph, name, values), and SETEASV(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name; not empty
  • sv the values (og_strvector_t), one per edge
Returns
OG_SUCCESS, or an error code (see errors).
Errors
  • OG_EINVAL the vector's length is not the number of edges
  • OG_EINVAL the attribute exists with a type other than string
  • OG_EINVAL name is NULL or empty, or the graph has no C-handler storage
  • OG_ENOMEM memory could not be allocated
Complexity
O(A + |E|)
Checked
used to load every attribute of the python-igraph comparisons (220 random graphs); fault injection shows a failed call changes nothing
C name
og_cattribute_EAS_setv
In notebooks
Og.Native.og_cattribute_EAS_setv
igraph 1.0
igraph_cattribute_EAS_setv
See also
cattribute_EAS_set, cattribute_EASV

cattribute_remove_g#

Exact

Deletes the graph attribute of a given name.

void og_cattribute_remove_g(og_t *graph, const char *name);

All values of the attribute are freed. A name the graph lacks gives a warning and changes nothing. Shorthand: OG_DELGA(graph, name), and DELGA(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
Nothing.
Complexity
O(A + number of values removed)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_remove_g
In notebooks
Og.Native.og_cattribute_remove_g
igraph 1.0
igraph_cattribute_remove_g
See also
cattribute_remove_all, cattribute_has_attr

cattribute_remove_v#

Exact

Deletes the vertex attribute of a given name.

void og_cattribute_remove_v(og_t *graph, const char *name);

All values of the attribute are freed. A name the graph lacks gives a warning and changes nothing. Shorthand: OG_DELVA(graph, name), and DELVA(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
Nothing.
Complexity
O(A + number of values removed)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_remove_v
In notebooks
Og.Native.og_cattribute_remove_v
igraph 1.0
igraph_cattribute_remove_v
See also
cattribute_remove_all, cattribute_has_attr

cattribute_remove_e#

Exact

Deletes the edge attribute of a given name.

void og_cattribute_remove_e(og_t *graph, const char *name);

All values of the attribute are freed. A name the graph lacks gives a warning and changes nothing. Shorthand: OG_DELEA(graph, name), and DELEA(...) unless OG_NO_SHORT_NAMES is defined.

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • name attribute name
Returns
Nothing.
Complexity
O(A + number of values removed)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_remove_e
In notebooks
Og.Native.og_cattribute_remove_e
igraph 1.0
igraph_cattribute_remove_e
See also
cattribute_remove_all, cattribute_has_attr

cattribute_remove_all#

Exact

Deletes every attribute of the chosen kinds: graph, vertex and/or edge.

void og_cattribute_remove_all(
    og_t *graph,
    og_bool_t g,
    og_bool_t v,
    og_bool_t e
);

Each flag selects one kind. A graph without C-handler storage is left alone. Shorthands: OG_DELGAS(graph), OG_DELVAS(graph), OG_DELEAS(graph) and OG_DELALL(graph) (also without the OG_ prefix unless OG_NO_SHORT_NAMES is defined).

Works on graphs whose attributes the C handler keeps: og_cattribute_table must be attached with set_attribute_table() before the graph is created.

Parameters
  • graph the graph
  • g remove the graph attributes
  • v remove the vertex attributes
  • e remove the edge attributes
Returns
Nothing.
Complexity
O(number of values removed)
Checked
values and attribute lists identical to python-igraph 1.0's after 300 random operation sequences
C name
og_cattribute_remove_all
In notebooks
Og.Native.og_cattribute_remove_all
igraph 1.0
igraph_cattribute_remove_all
See also
cattribute_remove_g, cattribute_remove_v, cattribute_remove_e

Last updated · Open Graph 0.1.0 · OpenBI Studio 0.3.78