Files
Abdelrahman Said a11edf0c53 Add graph references
2026-06-28 13:49:01 +01:00

7233 lines
252 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 10. Graph, vertex and edge attributes</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="igraph Reference Manual">
<link rel="up" href="index.html" title="igraph Reference Manual">
<link rel="prev" href="igraph-Iterators.html" title="Chapter 9. Vertex and edge selectors and sequences, iterators">
<link rel="next" href="igraph-Generators.html" title="Chapter 11. Deterministic graph generators">
<script type="text/javascript" src="toggle.js"></script><link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<link rel="chapter" href="igraph-Introduction.html" title="Chapter 1. Introduction">
<link rel="chapter" href="igraph-Installation.html" title="Chapter 2. Installation">
<link rel="chapter" href="igraph-Tutorial.html" title="Chapter 3. Tutorial">
<link rel="chapter" href="igraph-Basic.html" title="Chapter 4. Basic data types and interface">
<link rel="chapter" href="igraph-Error.html" title="Chapter 5. Error handling">
<link rel="chapter" href="igraph-Memory.html" title="Chapter 6. Memory (de)allocation">
<link rel="chapter" href="igraph-Data-structures.html" title="Chapter 7. Data structure library: vector, matrix, other data types">
<link rel="chapter" href="igraph-Random.html" title="Chapter 8. Random numbers">
<link rel="chapter" href="igraph-Iterators.html" title="Chapter 9. Vertex and edge selectors and sequences, iterators">
<link rel="chapter" href="igraph-Attributes.html" title="Chapter 10. Graph, vertex and edge attributes">
<link rel="chapter" href="igraph-Generators.html" title="Chapter 11. Deterministic graph generators">
<link rel="chapter" href="igraph-Games.html" title='Chapter 12. Stochastic graph generators ("games")'>
<link rel="chapter" href="igraph-Bipartite.html" title="Chapter 13. Bipartite, i.e. two-mode graphs">
<link rel="chapter" href="igraph-Spatial.html" title="Chapter 14. Spatial graphs">
<link rel="chapter" href="igraph-Operators.html" title="Chapter 15. Graph operators">
<link rel="chapter" href="igraph-Visitors.html" title="Chapter 16. Graph visitors">
<link rel="chapter" href="igraph-Structural.html" title="Chapter 17. Structural properties of graphs">
<link rel="chapter" href="igraph-Cycles.html" title="Chapter 18. Graph cycles">
<link rel="chapter" href="igraph-Cliques.html" title="Chapter 19. Cliques and independent vertex sets">
<link rel="chapter" href="igraph-Motifs.html" title="Chapter 20. Graph motifs, dyad census and triad census">
<link rel="chapter" href="igraph-Isomorphism.html" title="Chapter 21. Graph isomorphism">
<link rel="chapter" href="igraph-Coloring.html" title="Chapter 22. Graph coloring">
<link rel="chapter" href="igraph-Flows.html" title="Chapter 23. Maximum flows, minimum cuts and related measures">
<link rel="chapter" href="igraph-Separators.html" title="Chapter 24. Vertex separators">
<link rel="chapter" href="igraph-Community.html" title="Chapter 25. Detecting community structure">
<link rel="chapter" href="igraph-Graphlets.html" title="Chapter 26. Graphlets">
<link rel="chapter" href="igraph-HRG.html" title="Chapter 27. Hierarchical random graphs">
<link rel="chapter" href="igraph-Embedding.html" title="Chapter 28. Embedding of graphs">
<link rel="chapter" href="igraph-Layout.html" title="Chapter 29. Generating layouts for graph drawing">
<link rel="chapter" href="igraph-Processes.html" title="Chapter 30. Processes on graphs">
<link rel="chapter" href="igraph-Foreign.html" title="Chapter 31. Reading and writing graphs from and to files">
<link rel="chapter" href="igraph-Linalg.html" title="Chapter 32. Using BLAS, LAPACK and ARPACK for igraph matrices and graphs">
<link rel="chapter" href="igraph-Nongraph.html" title="Chapter 33. Non-graph related functions">
<link rel="chapter" href="igraph-Advanced.html" title="Chapter 34. Advanced igraph programming">
<link rel="chapter" href="igraph-Glossary.html" title="Chapter 35. Glossary">
<link rel="chapter" href="igraph-Licenses.html" title="Chapter 36. Licenses for igraph and this manual">
<link rel="index" href="ix01.html" title="Index">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navigation-header mb-4" width="100%" summary="Navigation header"><div class="btn-group">
<a accesskey="p" class="btn btn-light" href="igraph-Iterators.html"><i class="fa fa-chevron-left"></i>
Previous
</a><a accesskey="h" class="btn btn-light" href="index.html"><i class="fa fa-home"></i>
Home
</a><a accesskey="n" class="btn btn-light" href="igraph-Generators.html"><i class="fa fa-chevron-right"></i>
Next
</a>
</div></div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="igraph-Attributes"></a>Chapter 10. Graph, vertex and edge attributes</h1></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#attribute-handler-interface">1. The attribute handler interface</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#attribute-records">2. Attribute records</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#attribute-combinations">3. Handling attribute combination lists</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#accessing-attributes-from-c">4. Accessing attributes from C</a></span></dt>
</dl></div>
<p>Attributes are numbers, boolean values or strings associated with
the vertices or edges of a graph, or with the graph itself. E.g. you may
label vertices with symbolic names or attach numeric weights to the edges
of a graph. In addition to these three basic types, a custom object
type is supported as well.</p>
<p>igraph attributes are designed to be flexible and extensible.
In igraph attributes are implemented via an interface abstraction:
any type implementing the functions in the interface can be used
for storing vertex, edge and graph attributes. This means that
different attribute implementations can be used together with
igraph. This is reasonable: if igraph is used from Python attributes can be
of any Python type, from R all R types are allowed. There is also an
experimental attribute implementation to be used when programming
in C, but by default it is currently turned off.</p>
<p>First we briefly look over how attribute handlers can be
implemented. This is not something a user does every day. It is
rather typically the job of the high level interface writers. (But
it is possible to write an interface without implementing
attributes.) Then we show the experimental C attribute handler.</p>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="attribute-handler-interface"></a>1. The attribute handler interface</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_table_t">1.1. <code class="function">igraph_attribute_table_t</code> — Table of functions to perform operations on attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_set_attribute_table">1.2. <code class="function">igraph_set_attribute_table</code> — Attach an attribute table.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_type_t">1.3. <code class="function">igraph_attribute_type_t</code> — The possible types of the attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_elemtype_t">1.4. <code class="function">igraph_attribute_elemtype_t</code> — Types of objects to which attributes can be attached.</a></span></dt>
</dl></div>
<p>It is possible to attach an attribute handling
interface to <span class="command"><strong>igraph</strong></span>. This is simply a table of functions, of
type <a class="link" href="igraph-Attributes.html#igraph_attribute_table_t" title="1.1. igraph_attribute_table_t — Table of functions to perform operations on attributes."><code class="function">igraph_attribute_table_t</code></a>. These functions are invoked to
notify the attribute handling code about the structural changes in
a graph. See the documentation of this type for details.</p>
<p>By default there is no attribute interface attached to <span class="command"><strong>igraph</strong></span>.
To attach one, call <a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table."><code class="function">igraph_set_attribute_table</code></a> with your new
table. This is normally done on program startup, and is kept untouched
for the program's lifetime. It must be done before any graph object
is created, as graphs created with a given attribute handler
cannot be manipulated while a different attribute handler is
active.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_table_t"></a>1.1. <code class="function">igraph_attribute_table_t</code> — Table of functions to perform operations on attributes.</h3></div></div></div>
<a class="indexterm" name="id-1.11.5.4.2"></a><p>
</p>
<pre class="programlisting">
typedef struct igraph_attribute_table_t {
igraph_error_t (*init)(igraph_t *graph, const igraph_attribute_record_list_t *attr);
void (*destroy)(igraph_t *graph);
igraph_error_t (*copy)(igraph_t *to, const igraph_t *from, igraph_bool_t ga,
igraph_bool_t va, igraph_bool_t ea);
igraph_error_t (*add_vertices)(
igraph_t *graph, igraph_int_t nv,
const igraph_attribute_record_list_t *attr
);
igraph_error_t (*permute_vertices)(const igraph_t *graph,
igraph_t *newgraph,
const igraph_vector_int_t *idx);
igraph_error_t (*combine_vertices)(const igraph_t *graph,
igraph_t *newgraph,
const igraph_vector_int_list_t *merges,
const igraph_attribute_combination_t *comb);
igraph_error_t (*add_edges)(
igraph_t *graph, const igraph_vector_int_t *edges,
const igraph_attribute_record_list_t *attr
);
igraph_error_t (*permute_edges)(const igraph_t *graph,
igraph_t *newgraph, const igraph_vector_int_t *idx);
igraph_error_t (*combine_edges)(const igraph_t *graph,
igraph_t *newgraph,
const igraph_vector_int_list_t *merges,
const igraph_attribute_combination_t *comb);
igraph_error_t (*get_info)(const igraph_t *graph,
igraph_strvector_t *gnames, igraph_vector_int_t *gtypes,
igraph_strvector_t *vnames, igraph_vector_int_t *vtypes,
igraph_strvector_t *enames, igraph_vector_int_t *etypes);
igraph_bool_t (*has_attr)(const igraph_t *graph, igraph_attribute_elemtype_t type,
const char *name);
igraph_error_t (*get_type)(const igraph_t *graph, igraph_attribute_type_t *type,
igraph_attribute_elemtype_t elemtype, const char *name);
igraph_error_t (*get_numeric_graph_attr)(const igraph_t *graph, const char *name,
igraph_vector_t *value);
igraph_error_t (*get_string_graph_attr)(const igraph_t *graph, const char *name,
igraph_strvector_t *value);
igraph_error_t (*get_bool_graph_attr)(const igraph_t *igraph, const char *name,
igraph_vector_bool_t *value);
igraph_error_t (*get_numeric_vertex_attr)(const igraph_t *graph, const char *name,
igraph_vs_t vs,
igraph_vector_t *value);
igraph_error_t (*get_string_vertex_attr)(const igraph_t *graph, const char *name,
igraph_vs_t vs,
igraph_strvector_t *value);
igraph_error_t (*get_bool_vertex_attr)(const igraph_t *graph, const char *name,
igraph_vs_t vs,
igraph_vector_bool_t *value);
igraph_error_t (*get_numeric_edge_attr)(const igraph_t *graph, const char *name,
igraph_es_t es,
igraph_vector_t *value);
igraph_error_t (*get_string_edge_attr)(const igraph_t *graph, const char *name,
igraph_es_t es,
igraph_strvector_t *value);
igraph_error_t (*get_bool_edge_attr)(const igraph_t *graph, const char *name,
igraph_es_t es,
igraph_vector_bool_t *value);
} igraph_attribute_table_t;
</pre>
<p>
</p>
<p>
</p>
<p>This type collects the functions defining an attribute handler.
It has the following members:
</p>
<p><b>Values: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="constant">init</code>:</span></p></td>
<td><p>
This function is called whenever a new graph object is
created, right after it is created but before any vertices or
edges are added. It is supposed to set the <code class="constant">attr</code> member of the <code class="constant">igraph_t</code> object, which is guaranteed to be set to a null pointer
before this function is called. It is expected to set the <code class="constant">attr</code> member
to a non-null value <span class="emphasis"><em>or</em></span> return an error code. Leaving the <code class="constant">attr</code>
member at a null value while returning success is invalid and will trigger
an error in the C core of igraph itself.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">destroy</code>:</span></p></td>
<td><p>
This function is called whenever the graph object
is destroyed, right before freeing the allocated memory. It is supposed
to do any cleanup operations that are need to dispose of the <code class="constant">attr</code>
member of the <code class="constant">igraph_t</code> object properly. The caller will set the
<code class="constant">attr</code> member to a null pointer after this function returns.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">copy</code>:</span></p></td>
<td><p>
This function is called when the C core wants to populate the
attributes of a graph from another graph. The structure of the target
graph is already initialized by the time this function is called, and the
<code class="constant">attr</code> member of the graph is set to a null pointer. The function is
supposed to populate the <code class="constant">attr</code> member of the target <code class="constant">igraph_t</code> object
to a non-null value <span class="emphasis"><em>or</em></span> return an error code. Leaving the <code class="constant">attr</code>
member at a null value while returning success is invalid and will trigger
an error in the C core of igraph itself.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">add_vertices</code>:</span></p></td>
<td><p>
Called when vertices are added to a graph, after the
base data structure was modified. The number of vertices that were added is
supplied as an argument. The function is supposed to set up default values
for each vertex attribute that is currently registered on the graph, for
all the newly added vertices. Expected to return an error code.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">permute_vertices</code>:</span></p></td>
<td><p>
Called when a new graph is created based on an
existing one such that there is a mapping from the vertices of the new
graph back to the vertices of the old graph (e.g. if vertices are removed
from a graph). The supplied index vector defines which old vertex
a new vertex corresponds to. Its length is the same as the number of
vertices in the new graph, and for each new vertex it provides the ID
of the corresponding vertex in the old graph. The function is supposed to
set up the values of the vertex attributes of the new graph based on the
attributes of the old graph and the provided index vector. Note that the
old and the new graph <span class="emphasis"><em>may</em></span> be the same, in which case it is the
responsibility of the function to ensure that the operation can safely be
performed in-place. If the two graph instances are <span class="emphasis"><em>not</em></span> the same,
implementors may safely assume that the new graph has no vertex attributes
yet (but it may already have graph or edge attributes by the time this
function is called).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">combine_vertices</code>:</span></p></td>
<td><p>
This function is called when the creation
of a new graph involves a merge (contraction, etc.) of vertices
from another graph. The function is called after the new graph was created.
An argument specifies how several vertices from the old graph map to a
single vertex in the new graph. It is guaranteed that the old and the
new graph instances are different when this callback is called.
Implementors may safely assume that the new graph has no vertex attributes
yet (but it may already have graph or edge attributes by the time this
function is called).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">add_edges</code>:</span></p></td>
<td><p>
Called when new edges are added to a graph, after the
base data structure was modified. A vector containing the endpoints of the
new edges are supplied as an argument. The function is supposed to set up
default values for each edge attribute that is currently registered on the
graph, for all the newly added edges. Expected to return an error code.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">permute_edges</code>:</span></p></td>
<td><p>
Called when a new graph is created based on an
existing one such that some of the edges in the new graph should copy the
attributes of some edges from the old graph (this also includes the
deletion of edges). The supplied index vector defines which old edge a new
edge corresponds to. Its length is the same as the number of edges in the
new graph, and for each edge it provides the ID of the corresponding edge
in the old graph. The function is supposed to set up the values of the
edge attributes of the new graph based on the attributes of the old graph
and the provided index vector. Note that the old and the new graph <span class="emphasis"><em>may</em></span>
be the same, in which case it is the responsibility of the function to
ensure that the operation can safely be performed in-place. If the two
graph instances are <span class="emphasis"><em>not</em></span> the same, implementors may safely assume that
the new graph has no edge attributes yet (but it may already have graph or
vertex attributes by the time this function is called).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">combine_edges</code>:</span></p></td>
<td><p>
This function is called when the creation
of a new graph involves a merge (contraction, etc.) of edges
from another graph. The function is after the new graph was created.
An argument specifies how several edges from the old graph map to a
single edge in the new graph. It is guaranteed that the old and the
new graph instances are different when this callback is called.
Implementors may safely assume that the new graph has no edge attributes
yet (but it may already have graph or vertex attributes by the time this
function is called).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_info</code>:</span></p></td>
<td><p>
Query the attributes of a graph, the names and
types should be returned.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">has_attr</code>:</span></p></td>
<td><p>
Check whether a graph has the named
graph/vertex/edge attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_type</code>:</span></p></td>
<td><p>
Query the type of a graph/vertex/edge attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_numeric_graph_attr</code>:</span></p></td>
<td><p>
Query a numeric graph attribute. The
value should be appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions
should be made about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is
not guaranteed to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_string_graph_attr</code>:</span></p></td>
<td><p>
Query a string graph attribute. The
value should be appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions
should be made about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is
not guaranteed to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_bool_graph_attr</code>:</span></p></td>
<td><p>
Query a boolean graph attribute. The
value should be appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions
should be made about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is
not guaranteed to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_numeric_vertex_attr</code>:</span></p></td>
<td><p>
Query a numeric vertex attribute,
for the vertices included in <em class="parameter"><code>vs</code></em>. The attribute values should be
appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_string_vertex_attr</code>:</span></p></td>
<td><p>
Query a string vertex attribute,
for the vertices included in <em class="parameter"><code>vs</code></em>. The attribute values should be
appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_bool_vertex_attr</code>:</span></p></td>
<td><p>
Query a boolean vertex attribute,
for the vertices included in <em class="parameter"><code>vs</code></em>. The attribute values should be
appended to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_numeric_edge_attr</code>:</span></p></td>
<td><p>
Query a numeric edge attribute, for
the edges included in <em class="parameter"><code>es</code></em>. The attribute values should be appended
to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_string_edge_attr</code>:</span></p></td>
<td><p>
Query a string edge attribute, for the
the edges included in <em class="parameter"><code>es</code></em>. The attribute values should be appended
to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">get_bool_edge_attr</code>:</span></p></td>
<td><p>
Query a boolean edge attribute, for the
the edges included in <em class="parameter"><code>es</code></em>. The attribute values should be appended
to the provided <em class="parameter"><code>value</code></em> vector. No assumptions should be made
about the initial contents of the <em class="parameter"><code>value</code></em> vector and it is not guaranteed
to be empty.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_set_attribute_table"></a>1.2. <code class="function">igraph_set_attribute_table</code> — Attach an attribute table.</h3></div></div></div>
<a class="indexterm" name="id-1.11.5.5.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_attribute_table_t *
igraph_set_attribute_table(const igraph_attribute_table_t * table);
</pre></div>
<p>
</p>
<p>
This function attaches attribute handling code to the igraph library.
Note that the attribute handler table is <span class="emphasis"><em>not</em></span> thread-local even if
igraph is compiled in thread-local mode. In the vast majority of cases,
this is not a significant restriction.
</p>
<p>
Attribute handlers are normally attached on program startup, and are
left active for the program's lifetime. This is because a graph object
created with a given attribute handler must not be manipulated while
a different attribute handler is active.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>table</code></em>:</span></p></td>
<td><p>
Pointer to an <a class="link" href="igraph-Attributes.html#igraph_attribute_table_t" title="1.1. igraph_attribute_table_t — Table of functions to perform operations on attributes."><code class="function">igraph_attribute_table_t</code></a> object
containing the functions for attribute manipulation. Supply <code class="constant">NULL</code> here if you don't want attributes.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Pointer to the old attribute handling table.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_type_t"></a>1.3. <code class="function">igraph_attribute_type_t</code> — The possible types of the attributes.</h3></div></div></div>
<a class="indexterm" name="id-1.11.5.6.2"></a><p>
</p>
<pre class="programlisting">
typedef enum {
IGRAPH_ATTRIBUTE_UNSPECIFIED = 0,
IGRAPH_ATTRIBUTE_NUMERIC = 1,
IGRAPH_ATTRIBUTE_BOOLEAN = 2,
IGRAPH_ATTRIBUTE_STRING = 3,
IGRAPH_ATTRIBUTE_OBJECT = 127
} igraph_attribute_type_t;
</pre>
<p>
</p>
<p>
Values of this enum are used by the attribute interface to communicate the
type of an attribute to igraph's C core. When igraph is integrated in a
high-level language, the attribute type reported by the interface may not
necessarily have to match the exact data type in the high-level language as
long as the attribute interface can provide a conversion from the native
high-level attribute value to one of the data types listed here. When the
high-level data type is complex and has no suitable conversion to one of the
atomic igraph attribute types (numeric, string or Boolean), the attribute
interface should report the attribute as having an "object" type, which is
ignored by the C core. See also <a class="link" href="igraph-Attributes.html#igraph_attribute_table_t" title="1.1. igraph_attribute_table_t — Table of functions to perform operations on attributes."><code class="function">igraph_attribute_table_t</code></a>.
</p>
<p><b>Values: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_UNSPECIFIED</code>:</span></p></td>
<td><p>
Currently used internally
as a "null value" or "placeholder value" in some algorithms.
Attribute records with this type must not be passed to igraph
functions.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_NUMERIC</code>:</span></p></td>
<td><p>
Numeric attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_BOOLEAN</code>:</span></p></td>
<td><p>
Logical values, true or false.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_STRING</code>:</span></p></td>
<td><p>
String attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_OBJECT</code>:</span></p></td>
<td><p>
Custom attribute type, to be
used for special data types by client applications. The R and
Python interfaces use this for attributes that hold R or Python
objects. Usually ignored by igraph functions.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_elemtype_t"></a>1.4. <code class="function">igraph_attribute_elemtype_t</code> — Types of objects to which attributes can be attached.</h3></div></div></div>
<a class="indexterm" name="id-1.11.5.7.2"></a><p>
</p>
<pre class="programlisting">
typedef enum {
IGRAPH_ATTRIBUTE_GRAPH = 0,
IGRAPH_ATTRIBUTE_VERTEX,
IGRAPH_ATTRIBUTE_EDGE
} igraph_attribute_elemtype_t;
</pre>
<p>
</p>
<p>
</p>
<p><b>Values: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_GRAPH</code>:</span></p></td>
<td><p>
Denotes that an attribute belongs to the
entire graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_VERTEX</code>:</span></p></td>
<td><p>
Denotes that an attribute belongs to the
vertices of a graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_EDGE</code>:</span></p></td>
<td><p>
Denotes that an attribute belongs to the
edges of a graph.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="attribute-records"></a>2. Attribute records</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_t">2.1. <code class="function">igraph_attribute_record_t</code> — An attribute record holding the name, type and values of an attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_init">2.2. <code class="function">igraph_attribute_record_init</code> — Initializes an attribute record with a given name and type.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_init_copy">2.3. <code class="function">igraph_attribute_record_init_copy</code> — Initializes an attribute record by copying another record.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_size">2.4. <code class="function">igraph_attribute_record_size</code> — Returns the size of the value vector in an attribute record.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_resize">2.5. <code class="function">igraph_attribute_record_resize</code> — Resizes the value vector in an attribute record.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_set_name">2.6. <code class="function">igraph_attribute_record_set_name</code> — Sets the attribute name in an attribute record.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_set_type">2.7. <code class="function">igraph_attribute_record_set_type</code> — Sets the type of an attribute record.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_set_default_numeric">2.8. <code class="function">igraph_attribute_record_set_default_numeric</code> — Sets the default value of the attribute to the given number.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_set_default_string">2.9. <code class="function">igraph_attribute_record_set_default_string</code> — Sets the default value of the attribute to the given string.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_set_default_boolean">2.10. <code class="function">igraph_attribute_record_set_default_boolean</code> — Sets the default value of the attribute to the given logical value.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_record_destroy">2.11. <code class="function">igraph_attribute_record_destroy</code> — Destroys an attribute record.</a></span></dt>
</dl></div>
<p>Functions in the attribute handler interface may refer to
<span class="emphasis"><em>"attribute</em></span> records" or <span class="emphasis"><em>"attribute</em></span> record lists". An attribute record
is simply a triplet consisting of an attribute name, an attribute type and
a vector containing the values of the attribute. Attribute record lists are
typed containers that contain a sequence of attribute records. Attribute
record lists own the attribute records that they contain, and similarly,
attribute records own the vectors contained in them. Destroying an attribute
record destroys the vector of values inside it, and destroying an attribute
record list destroys all attribute records in the list.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_t"></a>2.1. <code class="function">igraph_attribute_record_t</code> — An attribute record holding the name, type and values of an attribute.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.3.2"></a><pre class="programlisting">
typedef struct igraph_attribute_record_t {
char *name;
</pre>
<p>
This composite data type is used in the attribute interface to specify a
name-type-value triplet where the name is the name of a graph, vertex or
edge attribute, the type is the corresponding igraph type of the attribute
and the value is a <span class="emphasis"><em>vector</em></span> of attribute values. Note that for graph
attributes we use a vector of length 1. The type of the vector depends on
the attribute type: it is <a class="link" href="igraph-Data-structures.html#igraph_vector_t" title="2.1.  About igraph_vector_t objects"><code class="function">igraph_vector_t</code></a> for numeric attributes,
<code class="constant">igraph_strvector_t</code> for string attributes and <code class="constant">igraph_vector_bool_t</code>
for Boolean attributes.
</p>
<p>
The record also stores default values for the attribute. The default values
are used when the value vector of the record is resized with
<a class="link" href="igraph-Attributes.html#igraph_attribute_record_resize" title="2.5. igraph_attribute_record_resize — Resizes the value vector in an attribute record."><code class="function">igraph_attribute_record_resize()</code></a>. It is important that the record
stores <span class="emphasis"><em>one</em></span> default value only, corresponding to the type of the
attribute record. The default value is <span class="emphasis"><em>cleared</em></span> when the type of the
record is changed.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_init"></a>2.2. <code class="function">igraph_attribute_record_init</code> — Initializes an attribute record with a given name and type.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_init(
igraph_attribute_record_t *attr, const char *name, igraph_attribute_type_t type
);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to initialize
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
name of the attribute
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em>:</span></p></td>
<td><p>
type of the attribute
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_init_copy"></a>2.3. <code class="function">igraph_attribute_record_init_copy</code> — Initializes an attribute record by copying another record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.5.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_init_copy(
igraph_attribute_record_t *to, const igraph_attribute_record_t *from
);
</pre></div>
<p>
</p>
<p>
</p>
<p>
Copies made by this function are deep copies: a full copy of the value
vector contained in the record is placed in the new record so they become
independent of each other.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>to</code></em>:</span></p></td>
<td><p>
the attribute record to initialize
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>from</code></em>:</span></p></td>
<td><p>
the attribute record to copy data from
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: operating system dependent, usually O(n), where n is the
size of the value vector in the attribute record.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_size"></a>2.4. <code class="function">igraph_attribute_record_size</code> — Returns the size of the value vector in an attribute record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_int_t igraph_attribute_record_size(const igraph_attribute_record_t *attr);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to query
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
the number of elements in the value vector of the attribute record
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_resize"></a>2.5. <code class="function">igraph_attribute_record_resize</code> — Resizes the value vector in an attribute record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.7.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_resize(
igraph_attribute_record_t *attr, igraph_int_t new_size
);
</pre></div>
<p>
</p>
<p>
</p>
<p>When the value vector is shorter than the desired length, it
will be expanded with <code class="constant">IGRAPH_NAN</code> for numeric vectors, <code class="constant">false</code> for Boolean
vectors and empty strings for string vectors.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>new_size</code></em>:</span></p></td>
<td><p>
the new size of the value vector
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory.
<code class="constant">IGRAPH_EINVAL</code> if the type of the attribute record is not specified yet.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_set_name"></a>2.6. <code class="function">igraph_attribute_record_set_name</code> — Sets the attribute name in an attribute record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.8.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_set_name(
igraph_attribute_record_t *attr, const char *name
);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
the new name
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_set_type"></a>2.7. <code class="function">igraph_attribute_record_set_type</code> — Sets the type of an attribute record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.9.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_set_type(
igraph_attribute_record_t *attr, igraph_attribute_type_t type
);
</pre></div>
<p>
</p>
<p>
</p>
<p>
When the new type being set is different from the old type, any values already
stored in the attribute record will be destroyed and a new, empty attribute
value vector will be allocated. When the new type is the same as the old
type, this function is a no-op.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em>:</span></p></td>
<td><p>
the new type
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_set_default_numeric"></a>2.8. <code class="function">igraph_attribute_record_set_default_numeric</code> — Sets the default value of the attribute to the given number.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.10.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_set_default_numeric(
igraph_attribute_record_t *attr, igraph_real_t value
);
</pre></div>
<p>
</p>
<p>
</p>
<p>
This function must be called for numeric attribute records only. When not
specified, the default value of numeric attributes is NaN.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
the new default value
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_EINVAL</code> if the attribute record has a non-numeric type
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_set_default_string"></a>2.9. <code class="function">igraph_attribute_record_set_default_string</code> — Sets the default value of the attribute to the given string.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.11.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_set_default_string(
igraph_attribute_record_t *attr, const char* value
);
</pre></div>
<p>
</p>
<p>
</p>
<p>
This function must be called for string attribute records only. When not
specified, the default value of string attributes is an empty string.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
the new default value. <code class="constant">NULL</code> means an empty string.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_ENOMEM</code> if there is not enough memory
<code class="constant">IGRAPH_EINVAL</code> if the attribute record is not of string type
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_set_default_boolean"></a>2.10. <code class="function">igraph_attribute_record_set_default_boolean</code> — Sets the default value of the attribute to the given logical value.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.12.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_record_set_default_boolean(
igraph_attribute_record_t *attr, igraph_bool_t value
);
</pre></div>
<p>
</p>
<p>
</p>
<p>
This function must be called for Boolean attribute records only. When not
specified, the default value of Boolean attributes is <code class="constant">false</code>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the attribute record to update
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
the new default value
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code:
<code class="constant">IGRAPH_EINVAL</code> if the attribute record is not of Boolean type
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_record_destroy"></a>2.11. <code class="function">igraph_attribute_record_destroy</code> — Destroys an attribute record.</h3></div></div></div>
<a class="indexterm" name="id-1.11.6.13.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_attribute_record_destroy(igraph_attribute_record_t *attr);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>attr</code></em>:</span></p></td>
<td><p>
the previously initialized attribute record to destroy.</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: operating system dependent.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="attribute-combinations"></a>3. Handling attribute combination lists</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination_init">3.1. <code class="function">igraph_attribute_combination_init</code> — Initialize attribute combination list.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination_add">3.2. <code class="function">igraph_attribute_combination_add</code> — Add combination record to attribute combination list.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination_remove">3.3. <code class="function">igraph_attribute_combination_remove</code> — Remove a record from an attribute combination list.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination_destroy">3.4. <code class="function">igraph_attribute_combination_destroy</code> — Destroy attribute combination list.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination_type_t">3.5. <code class="function">igraph_attribute_combination_type_t</code> — The possible types of attribute combinations.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_attribute_combination">3.6. <code class="function">igraph_attribute_combination</code> — Initialize attribute combination list and add records.</a></span></dt>
</dl></div>
<p>Several graph operations may collapse multiple vertices or edges into
a single one. Attribute combination lists are used to indicate to the attribute
handler how to combine the attributes of the original vertices or edges and
how to derive the final attribute value that is to be assigned to the collapsed
vertex or edge. For example, <a class="link" href="igraph-Operators.html#igraph_simplify" title="3.11. igraph_simplify — Removes loop and/or multiple edges from the graph."><code class="function">igraph_simplify()</code></a> removes loops and combines
multiple edges into a single one; in case of a graph with an edge attribute
named <code class="constant">weight</code> the attribute combination list can tell the attribute handler
whether the weight of a collapsed edge should be the sum, the mean or some other
function of the weights of the original edges that were collapsed into one.</p>
<p>One attribute combination list may contain several attribute combination
records, one for each vertex or edge attribute that is to be handled during the
operation.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination_init"></a>3.1. <code class="function">igraph_attribute_combination_init</code> — Initialize attribute combination list.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_combination_init(igraph_attribute_combination_t *comb);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>comb</code></em>:</span></p></td>
<td><p>
The uninitialized attribute combination list.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(1)
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination_add"></a>3.2. <code class="function">igraph_attribute_combination_add</code> — Add combination record to attribute combination list.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.5.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_combination_add(igraph_attribute_combination_t *comb,
const char *name,
igraph_attribute_combination_type_t type,
igraph_function_pointer_t func);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>comb</code></em>:</span></p></td>
<td><p>
The attribute combination list.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute. If the name already exists
the attribute combination record will be replaced.
Use NULL to add a default combination record for all
atributes not in the list.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em>:</span></p></td>
<td><p>
The type of the attribute combination. See <a class="link" href="igraph-Attributes.html#igraph_attribute_combination_type_t" title="3.5. igraph_attribute_combination_type_t — The possible types of attribute combinations."><code class="function">igraph_attribute_combination_type_t</code></a> for the options.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>:</span></p></td>
<td><p>
Function to be used if <em class="parameter"><code>type</code></em> is
<code class="constant">IGRAPH_ATTRIBUTE_COMBINE_FUNCTION</code>. This function is called
by the concrete attribute handler attached to igraph, and its
calling signature depends completely on the attribute handler.
For instance, if you are using attributes from C and you have
attached the C attribute handler, you need to follow the
documentation of the <a class="link" href="igraph-Attributes.html#c-attribute-combination-functions" title="4.4. Custom attribute combination functions">C attribute handler</a>
for more details.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), where n is the number of current attribute
combinations.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination_remove"></a>3.3. <code class="function">igraph_attribute_combination_remove</code> — Remove a record from an attribute combination list.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_combination_remove(igraph_attribute_combination_t *comb,
const char *name);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>comb</code></em>:</span></p></td>
<td><p>
The attribute combination list.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The attribute name of the attribute combination record
to remove. It will be ignored if the named attribute
does not exist. It can be NULL to remove the default
combination record.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code. This currently always returns IGRAPH_SUCCESS.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), where n is the number of records in the attribute
combination list.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination_destroy"></a>3.4. <code class="function">igraph_attribute_combination_destroy</code> — Destroy attribute combination list.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.7.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_attribute_combination_destroy(igraph_attribute_combination_t *comb);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>comb</code></em>:</span></p></td>
<td><p>
The attribute combination list.</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), where n is the number of records in the
attribute combination list.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination_type_t"></a>3.5. <code class="function">igraph_attribute_combination_type_t</code> — The possible types of attribute combinations.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.8.2"></a><p>
</p>
<pre class="programlisting">
typedef enum {
IGRAPH_ATTRIBUTE_COMBINE_IGNORE = 0,
IGRAPH_ATTRIBUTE_COMBINE_DEFAULT = 1,
IGRAPH_ATTRIBUTE_COMBINE_FUNCTION = 2,
IGRAPH_ATTRIBUTE_COMBINE_SUM = 3,
IGRAPH_ATTRIBUTE_COMBINE_PROD = 4,
IGRAPH_ATTRIBUTE_COMBINE_MIN = 5,
IGRAPH_ATTRIBUTE_COMBINE_MAX = 6,
IGRAPH_ATTRIBUTE_COMBINE_RANDOM = 7,
IGRAPH_ATTRIBUTE_COMBINE_FIRST = 8,
IGRAPH_ATTRIBUTE_COMBINE_LAST = 9,
IGRAPH_ATTRIBUTE_COMBINE_MEAN = 10,
IGRAPH_ATTRIBUTE_COMBINE_MEDIAN = 11,
IGRAPH_ATTRIBUTE_COMBINE_CONCAT = 12
} igraph_attribute_combination_type_t;
</pre>
<p>
</p>
<p>
</p>
<p><b>Values: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_IGNORE</code>:</span></p></td>
<td><p>
Ignore old attributes, use an empty value.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_DEFAULT</code>:</span></p></td>
<td><p>
Use the default way to combine attributes (decided by the attribute handler implementation).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_FUNCTION</code>:</span></p></td>
<td><p>
Supply your own function to combine
attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_SUM</code>:</span></p></td>
<td><p>
Take the sum of the attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_PROD</code>:</span></p></td>
<td><p>
Take the product of the attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_MIN</code>:</span></p></td>
<td><p>
Take the minimum attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_MAX</code>:</span></p></td>
<td><p>
Take the maximum attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_RANDOM</code>:</span></p></td>
<td><p>
Take a random attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_FIRST</code>:</span></p></td>
<td><p>
Take the first attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_LAST</code>:</span></p></td>
<td><p>
Take the last attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_MEAN</code>:</span></p></td>
<td><p>
Take the mean of the attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_MEDIAN</code>:</span></p></td>
<td><p>
Take the median of the attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">IGRAPH_ATTRIBUTE_COMBINE_CONCAT</code>:</span></p></td>
<td><p>
Concatenate the attributes.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_attribute_combination"></a>3.6. <code class="function">igraph_attribute_combination</code> — Initialize attribute combination list and add records.</h3></div></div></div>
<a class="indexterm" name="id-1.11.7.9.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_attribute_combination(
igraph_attribute_combination_t *comb, ...);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>comb</code></em>:</span></p></td>
<td><p>
The uninitialized attribute combination list.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em>:</span></p></td>
<td><p>
A list of 'name, type[, func]', where:
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute. If the name already exists
the attribute combination record will be replaced.
Use NULL to add a default combination record for all
atributes not in the list.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em>:</span></p></td>
<td><p>
The type of the attribute combination. See <a class="link" href="igraph-Attributes.html#igraph_attribute_combination_type_t" title="3.5. igraph_attribute_combination_type_t — The possible types of attribute combinations."><code class="function">igraph_attribute_combination_type_t</code></a> for the options.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>:</span></p></td>
<td><p>
Function to be used if <em class="parameter"><code>type</code></em> is
<code class="constant">IGRAPH_ATTRIBUTE_COMBINE_FUNCTION</code>.
The list is closed by setting the name to <code class="constant">IGRAPH_NO_MORE_ATTRIBUTES</code>.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n^2), where n is the number attribute
combinations records to add.
</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.11.7.9.8.1"></a><p class="title"><b>Example 10.1.  File <code class="code">examples/simple/igraph_attribute_combination.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t graph;
igraph_attribute_combination_t comb;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table.">igraph_set_attribute_table</a></strong></span>(&amp;igraph_cattribute_table);
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_small" title="2.2. igraph_small — Shorthand to create a small graph, giving the edges as arguments.">igraph_small</a></strong></span>(&amp;graph, 2, IGRAPH_DIRECTED,
0,1, 0,1,
-1);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAB" title="4.2.16. SETEAB — Set a boolean edge attribute">SETEAB</a></strong></span>(&amp;graph, "type", 0, true);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAB" title="4.2.16. SETEAB — Set a boolean edge attribute">SETEAB</a></strong></span>(&amp;graph, "type", 1, false);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"weight", IGRAPH_ATTRIBUTE_COMBINE_SUM,
"type", IGRAPH_ATTRIBUTE_COMBINE_FIRST,
"", IGRAPH_ATTRIBUTE_COMBINE_IGNORE,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong><a class="link" href="igraph-Operators.html#igraph_simplify" title="3.11. igraph_simplify — Removes loop and/or multiple edges from the graph.">igraph_simplify</a></strong></span>(&amp;graph, <span class="emphasis"><em>/*remove_multiple=*/</em></span> true, <span class="emphasis"><em>/*remove_loops=*/</em></span> true, &amp;comb);
<span class="strong"><strong><a class="link" href="igraph-Foreign.html#igraph_write_graph_graphml" title="3.2. igraph_write_graph_graphml — Writes the graph to a file in GraphML format.">igraph_write_graph_graphml</a></strong></span>(&amp;graph, stdout, <span class="emphasis"><em>/*prefixattr=*/</em></span> true);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination_destroy" title="3.4. igraph_attribute_combination_destroy — Destroy attribute combination list.">igraph_attribute_combination_destroy</a></strong></span>(&amp;comb);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<p>
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="accessing-attributes-from-c"></a>4. Accessing attributes from C</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#query-attributes">4.1. Query attributes</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#set-attributes">4.2. Set attributes</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#remove-attributes">4.3. Remove attributes</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#c-attribute-combination-functions">4.4. Custom attribute combination functions</a></span></dt>
</dl></div>
<p>There is an experimental attribute handler that can be used
from C code. In this section we show how this works. This attribute
handler is by default not attached (the default is no attribute
handler), so we first need to attach it:
</p>
<pre class="programlisting">
igraph_set_attribute_table(&amp;igraph_cattribute_table);
</pre>
<p>
</p>
<p>Now the attribute functions are available. Please note that
the attribute handler must be attached before you call any other
igraph functions, otherwise you might end up with graphs without
attributes and an active attribute handler, which might cause
unexpected program behaviour. The rule is that you attach the
attribute handler in the beginning of your
<code class="function">main()</code> and never touch it again. Detaching
the attribute handler might lead to memory leaks.</p>
<p>It is not currently possible to have attribute handlers on a
per-graph basis. All graphs in an application must be managed with
the same attribute handler. This also applies to the default case
when there is no attribute handler at all.</p>
<p>The C attribute handler supports attaching real numbers, boolean
values and character strings as attributes. No vector values are allowed.
For example, vertices have a <code class="literal">name</code> attribute holding a single
string value for each vertex, but it is not possible to have a <code class="literal">coords</code>
attribute which is a vector of numbers per vertex.</p>
<p>The functions documented in this section are specific to the C
attribute handler. Code using these functions will not function when
a different attribute handler is attached.</p>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.11.8.7"></a><p class="title"><b>Example 10.2.  File <code class="code">examples/simple/cattributes.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;string.h&gt;
<span class="strong"><strong>#include</strong></span> &lt;stdlib.h&gt;
<span class="emphasis"><em>/* Prints graph, vertex and edge attributes stored in a graph. */</em></span>
void <span class="strong"><strong>print_attributes</strong></span>(<span class="strong"><strong>const</strong></span> igraph_t *g) {
igraph_vector_int_t gtypes, vtypes, etypes;
igraph_strvector_t gnames, vnames, enames;
igraph_int_t i, j;
<span class="strong"><strong>igraph_vector_int_init</strong></span>(&amp;gtypes, 0);
<span class="strong"><strong>igraph_vector_int_init</strong></span>(&amp;vtypes, 0);
<span class="strong"><strong>igraph_vector_int_init</strong></span>(&amp;etypes, 0);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_init" title="8.1. igraph_strvector_init — Initializes a string vector.">igraph_strvector_init</a></strong></span>(&amp;gnames, 0);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_init" title="8.1. igraph_strvector_init — Initializes a string vector.">igraph_strvector_init</a></strong></span>(&amp;vnames, 0);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_init" title="8.1. igraph_strvector_init — Initializes a string vector.">igraph_strvector_init</a></strong></span>(&amp;enames, 0);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_cattribute_list" title="4.1.1. igraph_cattribute_list — List all attributes.">igraph_cattribute_list</a></strong></span>(g,
&amp;gnames, &amp;gtypes,
&amp;vnames, &amp;vtypes,
&amp;enames, &amp;etypes);
<span class="emphasis"><em>/* graph attributes */</em></span>
<span class="strong"><strong>for</strong></span> (i = 0; i &lt; <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_size" title="8.21. igraph_strvector_size — Returns the size of a string vector.">igraph_strvector_size</a></strong></span>(&amp;gnames); i++) {
<span class="strong"><strong>printf</strong></span>("%s=", <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;gnames, i));
<span class="strong"><strong>if</strong></span> (<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(gtypes)[i] == IGRAPH_ATTRIBUTE_NUMERIC) {
<span class="strong"><strong>igraph_real_printf</strong></span>(<span class="strong"><strong><a class="link" href="igraph-Attributes.html#GAN" title="4.1.4. GAN — Query a numeric graph attribute.">GAN</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;gnames, i)));
<span class="strong"><strong>putchar</strong></span>(' ');
} <span class="strong"><strong>else</strong></span> {
<span class="strong"><strong>printf</strong></span>("\"%s\" ", <span class="strong"><strong><a class="link" href="igraph-Attributes.html#GAS" title="4.1.8. GAS — Query a string graph attribute.">GAS</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;gnames, i)));
}
}
<span class="strong"><strong>printf</strong></span>("\n");
<span class="emphasis"><em>/* vertex attributes */</em></span>
<span class="strong"><strong>for</strong></span> (i = 0; i &lt; <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_vcount" title="5.2.1. igraph_vcount — The number of vertices in a graph.">igraph_vcount</a></strong></span>(g); i++) {
<span class="strong"><strong>printf</strong></span>("Vertex %" IGRAPH_PRId ": ", i);
<span class="strong"><strong>for</strong></span> (j = 0; j &lt; <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_size" title="8.21. igraph_strvector_size — Returns the size of a string vector.">igraph_strvector_size</a></strong></span>(&amp;vnames); j++) {
<span class="strong"><strong>printf</strong></span>("%s=", <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;vnames, j));
<span class="strong"><strong>if</strong></span> (<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(vtypes)[j] == IGRAPH_ATTRIBUTE_NUMERIC) {
<span class="strong"><strong>igraph_real_printf</strong></span>(<span class="strong"><strong><a class="link" href="igraph-Attributes.html#VAN" title="4.1.10. VAN — Query a numeric vertex attribute.">VAN</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;vnames, j), i));
<span class="strong"><strong>putchar</strong></span>(' ');
} <span class="strong"><strong>else</strong></span> {
<span class="strong"><strong>printf</strong></span>("\"%s\" ", <span class="strong"><strong><a class="link" href="igraph-Attributes.html#VAS" title="4.1.18. VAS — Query a string vertex attribute.">VAS</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;vnames, j), i));
}
}
<span class="strong"><strong>printf</strong></span>("\n");
}
<span class="emphasis"><em>/* edge attributes */</em></span>
<span class="strong"><strong>for</strong></span> (i = 0; i &lt; <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_ecount" title="5.2.2. igraph_ecount — The number of edges in a graph.">igraph_ecount</a></strong></span>(g); i++) {
<span class="strong"><strong>printf</strong></span>("Edge %" IGRAPH_PRId " (%" IGRAPH_PRId "-%" IGRAPH_PRId "): ", i, <span class="strong"><strong><a class="link" href="igraph-Basic.html#IGRAPH_FROM" title="5.2.6. IGRAPH_FROM — The source vertex of an edge.">IGRAPH_FROM</a></strong></span>(g, i), <span class="strong"><strong><a class="link" href="igraph-Basic.html#IGRAPH_TO" title="5.2.7. IGRAPH_TO — The target vertex of an edge.">IGRAPH_TO</a></strong></span>(g, i));
<span class="strong"><strong>for</strong></span> (j = 0; j &lt; <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_size" title="8.21. igraph_strvector_size — Returns the size of a string vector.">igraph_strvector_size</a></strong></span>(&amp;enames); j++) {
<span class="strong"><strong>printf</strong></span>("%s=", <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;enames, j));
<span class="strong"><strong>if</strong></span> (<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#VECTOR" title="2.4.1. VECTOR — Accessing an element of a vector.">VECTOR</a></strong></span>(etypes)[j] == IGRAPH_ATTRIBUTE_NUMERIC) {
<span class="strong"><strong>igraph_real_printf</strong></span>(<span class="strong"><strong><a class="link" href="igraph-Attributes.html#EAN" title="4.1.22. EAN — Query a numeric edge attribute.">EAN</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;enames, j), i));
<span class="strong"><strong>putchar</strong></span>(' ');
} <span class="strong"><strong>else</strong></span> {
<span class="strong"><strong>printf</strong></span>("\"%s\" ", <span class="strong"><strong><a class="link" href="igraph-Attributes.html#EAS" title="4.1.30. EAS — Query a string edge attribute.">EAS</a></strong></span>(g, <span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_get" title="8.5. igraph_strvector_get — Retrieves an element of a string vector.">igraph_strvector_get</a></strong></span>(&amp;enames, j), i));
}
}
<span class="strong"><strong>printf</strong></span>("\n");
}
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_destroy" title="8.3. igraph_strvector_destroy — Frees the memory allocated for the string vector.">igraph_strvector_destroy</a></strong></span>(&amp;enames);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_destroy" title="8.3. igraph_strvector_destroy — Frees the memory allocated for the string vector.">igraph_strvector_destroy</a></strong></span>(&amp;vnames);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_strvector_destroy" title="8.3. igraph_strvector_destroy — Frees the memory allocated for the string vector.">igraph_strvector_destroy</a></strong></span>(&amp;gnames);
<span class="strong"><strong>igraph_vector_int_destroy</strong></span>(&amp;etypes);
<span class="strong"><strong>igraph_vector_int_destroy</strong></span>(&amp;vtypes);
<span class="strong"><strong>igraph_vector_int_destroy</strong></span>(&amp;gtypes);
}
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t graph;
<a class="link" href="igraph-Data-structures.html#igraph_vector_t" title="2.1.  About igraph_vector_t objects">igraph_vector_t</a> y;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="emphasis"><em>/* Turn on attribute handling. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table.">igraph_set_attribute_table</a></strong></span>(&amp;igraph_cattribute_table);
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_small" title="2.2. igraph_small — Shorthand to create a small graph, giving the edges as arguments.">igraph_small</a></strong></span>(&amp;graph, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1);
<span class="emphasis"><em>/* Set graph attributes. */</em></span>
<span class="emphasis"><em>/* numeric */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAN" title="4.2.2. SETGAN — Set a numeric graph attribute">SETGAN</a></strong></span>(&amp;graph, "id", 10);
<span class="emphasis"><em>/* string */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAS" title="4.2.6. SETGAS — Set a string graph attribute">SETGAS</a></strong></span>(&amp;graph, "name", "toy");
<span class="emphasis"><em>/* boolean */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAB" title="4.2.4. SETGAB — Set a boolean graph attribute">SETGAB</a></strong></span>(&amp;graph, "is_regular", false);
<span class="emphasis"><em>/* Set edge string attribute. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;graph, "color", 1, "RED");
<span class="emphasis"><em>/* Set vertex attributes as vector. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_init" title="2.2.1. igraph_vector_init — Initializes a vector object (constructor).">igraph_vector_init</a></strong></span>(&amp;y, <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_vcount" title="5.2.1. igraph_vcount — The number of vertices in a graph.">igraph_vcount</a></strong></span>(&amp;graph));
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_fill" title="2.3.2. igraph_vector_fill — Fill a vector with a constant element.">igraph_vector_fill</a></strong></span>(&amp;y, 1.23);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVANV" title="4.2.20. SETVANV — Set a numeric vertex attribute for all vertices">SETVANV</a></strong></span>(&amp;graph, "y", &amp;y);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_destroy" title="2.2.5. igraph_vector_destroy — Destroys a vector object.">igraph_vector_destroy</a></strong></span>(&amp;y);
<span class="emphasis"><em>/* Set single vertex numeric attribute. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVAN" title="4.2.8. SETVAN — Set a numeric vertex attribute">SETVAN</a></strong></span>(&amp;graph, "y", 0, -1);
<span class="emphasis"><em>/* Delete graph attribute. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#DELGA" title="4.3.2. DELGA — Remove a graph attribute.">DELGA</a></strong></span>(&amp;graph, "is_regular");
<span class="emphasis"><em>/* Print the final result. */</em></span>
<span class="strong"><strong>print_attributes</strong></span>(&amp;graph);
<span class="emphasis"><em>/* Delete all remaining attributes. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#DELALL" title="4.3.11. DELALL — Remove all attributes.">DELALL</a></strong></span>(&amp;graph);
<span class="emphasis"><em>/* Destroy the graph. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;graph);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.11.8.8"></a><p class="title"><b>Example 10.3.  File <code class="code">examples/simple/cattributes2.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t g;
<a class="link" href="igraph-Data-structures.html#igraph_vector_t" title="2.1.  About igraph_vector_t objects">igraph_vector_t</a> y;
<a class="link" href="igraph-Error.html#igraph_warning_handler_t" title="4.1. igraph_warning_handler_t — The type of igraph warning handler functions.">igraph_warning_handler_t</a>* oldwarnhandler;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="emphasis"><em>/* Turn on attribute handling. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table.">igraph_set_attribute_table</a></strong></span>(&amp;igraph_cattribute_table);
<span class="emphasis"><em>/* Create a graph, add some attributes and save it as a GraphML file. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_famous" title="8.1. igraph_famous — Create a famous graph by simply providing its name.">igraph_famous</a></strong></span>(&amp;g, "Petersen");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAS" title="4.2.6. SETGAS — Set a string graph attribute">SETGAS</a></strong></span>(&amp;g, "name", "Petersen's graph");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAN" title="4.2.2. SETGAN — Set a numeric graph attribute">SETGAN</a></strong></span>(&amp;g, "vertices", <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_vcount" title="5.2.1. igraph_vcount — The number of vertices in a graph.">igraph_vcount</a></strong></span>(&amp;g));
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAN" title="4.2.2. SETGAN — Set a numeric graph attribute">SETGAN</a></strong></span>(&amp;g, "edges", <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_ecount" title="5.2.2. igraph_ecount — The number of edges in a graph.">igraph_ecount</a></strong></span>(&amp;g));
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETGAB" title="4.2.4. SETGAB — Set a boolean graph attribute">SETGAB</a></strong></span>(&amp;g, "famous", true);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_init_range" title="2.2.4. igraph_vector_init_range — Initializes a vector with a range.">igraph_vector_init_range</a></strong></span>(&amp;y, 1, <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_vcount" title="5.2.1. igraph_vcount — The number of vertices in a graph.">igraph_vcount</a></strong></span>(&amp;g) + 1);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVANV" title="4.2.20. SETVANV — Set a numeric vertex attribute for all vertices">SETVANV</a></strong></span>(&amp;g, "id", &amp;y);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_destroy" title="2.2.5. igraph_vector_destroy — Destroys a vector object.">igraph_vector_destroy</a></strong></span>(&amp;y);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVAS" title="4.2.12. SETVAS — Set a string vertex attribute">SETVAS</a></strong></span>(&amp;g, "name", 0, "foo");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVAS" title="4.2.12. SETVAS — Set a string vertex attribute">SETVAS</a></strong></span>(&amp;g, "name", 1, "foobar");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETVAB" title="4.2.10. SETVAB — Set a boolean vertex attribute">SETVAB</a></strong></span>(&amp;g, "is_first", 0, true);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_init_range" title="2.2.4. igraph_vector_init_range — Initializes a vector with a range.">igraph_vector_init_range</a></strong></span>(&amp;y, 1, <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_ecount" title="5.2.2. igraph_ecount — The number of edges in a graph.">igraph_ecount</a></strong></span>(&amp;g) + 1);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEANV" title="4.2.26. SETEANV — Set a numeric edge attribute for all edges">SETEANV</a></strong></span>(&amp;g, "id", &amp;y);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_destroy" title="2.2.5. igraph_vector_destroy — Destroys a vector object.">igraph_vector_destroy</a></strong></span>(&amp;y);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "name", 0, "FOO");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "name", 1, "FOOBAR");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAB" title="4.2.16. SETEAB — Set a boolean edge attribute">SETEAB</a></strong></span>(&amp;g, "is_first", 0, true);
<span class="emphasis"><em>/* Turn off the warning handler temporarily because the GML writer will</em></span>
<span class="emphasis"><em> * print warnings about boolean attributes being converted to numbers, and</em></span>
<span class="emphasis"><em> * we don't care about these. */</em></span>
oldwarnhandler = <span class="strong"><strong><a class="link" href="igraph-Error.html#igraph_set_warning_handler" title="4.2. igraph_set_warning_handler — Installs a warning handler.">igraph_set_warning_handler</a></strong></span>(<a class="link" href="igraph-Error.html#igraph_warning_handler_ignore" title="4.7. igraph_warning_handler_ignore — Ignores all warnings.">igraph_warning_handler_ignore</a>);
<span class="strong"><strong><a class="link" href="igraph-Foreign.html#igraph_write_graph_gml" title="4.2. igraph_write_graph_gml — Write the graph to a stream in GML format.">igraph_write_graph_gml</a></strong></span>(&amp;g, stdout, IGRAPH_WRITE_GML_DEFAULT_SW, 0, "");
<span class="strong"><strong><a class="link" href="igraph-Error.html#igraph_set_warning_handler" title="4.2. igraph_set_warning_handler — Installs a warning handler.">igraph_set_warning_handler</a></strong></span>(oldwarnhandler);
<span class="emphasis"><em>/* Back to business. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Foreign.html#igraph_write_graph_graphml" title="3.2. igraph_write_graph_graphml — Writes the graph to a file in GraphML format.">igraph_write_graph_graphml</a></strong></span>(&amp;g, stdout, <span class="emphasis"><em>/*prefixattr=*/</em></span> true);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;g);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.11.8.9"></a><p class="title"><b>Example 10.4.  File <code class="code">examples/simple/cattributes3.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<a class="link" href="igraph-Error.html#igraph_error_t" title="3.1. igraph_error_t — Return type for functions returning an error code.">igraph_error_t</a> <span class="strong"><strong>mf</strong></span>(<span class="strong"><strong>const</strong></span> <a class="link" href="igraph-Data-structures.html#igraph_vector_t" title="2.1.  About igraph_vector_t objects">igraph_vector_t</a> *input, igraph_real_t *output) {
*output = 0.0;
<span class="strong"><strong>return</strong></span> IGRAPH_SUCCESS;
}
<span class="strong"><strong>static</strong></span> void <span class="strong"><strong>simplify_write_destroy</strong></span>(igraph_t *g, igraph_attribute_combination_t *comb) {
<span class="strong"><strong><a class="link" href="igraph-Operators.html#igraph_simplify" title="3.11. igraph_simplify — Removes loop and/or multiple edges from the graph.">igraph_simplify</a></strong></span>(g, <span class="emphasis"><em>/*remove_multiple=*/</em></span> true, <span class="emphasis"><em>/*remove_loops=*/</em></span> true, comb);
<span class="strong"><strong><a class="link" href="igraph-Foreign.html#igraph_write_graph_graphml" title="3.2. igraph_write_graph_graphml — Writes the graph to a file in GraphML format.">igraph_write_graph_graphml</a></strong></span>(g, stdout, <span class="emphasis"><em>/*prefixattr=*/</em></span> true);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination_destroy" title="3.4. igraph_attribute_combination_destroy — Destroy attribute combination list.">igraph_attribute_combination_destroy</a></strong></span>(comb);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(g);
}
<span class="strong"><strong>static</strong></span> void <span class="strong"><strong>weight_test</strong></span>(igraph_t *g, <a class="link" href="igraph-Attributes.html#igraph_attribute_combination_type_t" title="3.5. igraph_attribute_combination_type_t — The possible types of attribute combinations.">igraph_attribute_combination_type_t</a> weight_attr) {
igraph_t g2;
igraph_attribute_combination_t comb;
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"weight", weight_attr,
"", IGRAPH_ATTRIBUTE_COMBINE_IGNORE,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
}
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t g, g2;
<a class="link" href="igraph-Data-structures.html#igraph_vector_t" title="2.1.  About igraph_vector_t objects">igraph_vector_t</a> weight;
igraph_attribute_combination_t comb;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table.">igraph_set_attribute_table</a></strong></span>(&amp;igraph_cattribute_table);
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_small" title="2.2. igraph_small — Shorthand to create a small graph, giving the edges as arguments.">igraph_small</a></strong></span>(&amp;g, 4, IGRAPH_DIRECTED,
0, 1, 0, 1, 0, 1,
1, 2, 2, 3,
-1);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_init_range" title="2.2.4. igraph_vector_init_range — Initializes a vector with a range.">igraph_vector_init_range</a></strong></span>(&amp;weight, 1, <span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_ecount" title="5.2.2. igraph_ecount — The number of edges in a graph.">igraph_ecount</a></strong></span>(&amp;g) + 1);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEANV" title="4.2.26. SETEANV — Set a numeric edge attribute for all edges">SETEANV</a></strong></span>(&amp;g, "weight", &amp;weight);
<span class="strong"><strong><a class="link" href="igraph-Data-structures.html#igraph_vector_destroy" title="2.2.5. igraph_vector_destroy — Destroys a vector object.">igraph_vector_destroy</a></strong></span>(&amp;weight);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_SUM);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_PROD);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_MIN);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_MAX);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_FIRST);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_LAST);
<span class="strong"><strong>weight_test</strong></span>(&amp;g, IGRAPH_ATTRIBUTE_COMBINE_MEAN);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, &amp;g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"weight", IGRAPH_ATTRIBUTE_COMBINE_FUNCTION, mf,
"", IGRAPH_ATTRIBUTE_COMBINE_IGNORE,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, &amp;g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"", IGRAPH_ATTRIBUTE_COMBINE_MEAN,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;g);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<div class="hideshow" onClick="toggle(this, event)">
<div class="example">
<a name="id-1.11.8.10"></a><p class="title"><b>Example 10.5.  File <code class="code">examples/simple/cattributes4.c</code></b></p>
<div class="example-contents">
<pre class="programlisting"><span class="strong"><strong>#include</strong></span> &lt;igraph.h&gt;
<span class="strong"><strong>static</strong></span> void <span class="strong"><strong>simplify_write_destroy</strong></span>(igraph_t *g, igraph_attribute_combination_t *comb) {
<span class="strong"><strong><a class="link" href="igraph-Operators.html#igraph_simplify" title="3.11. igraph_simplify — Removes loop and/or multiple edges from the graph.">igraph_simplify</a></strong></span>(g, <span class="emphasis"><em>/*remove_multiple=*/</em></span> true, <span class="emphasis"><em>/*remove_loops=*/</em></span> true, comb);
<span class="strong"><strong><a class="link" href="igraph-Foreign.html#igraph_write_graph_graphml" title="3.2. igraph_write_graph_graphml — Writes the graph to a file in GraphML format.">igraph_write_graph_graphml</a></strong></span>(g, stdout, <span class="emphasis"><em>/*prefixattr=*/</em></span> true);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination_destroy" title="3.4. igraph_attribute_combination_destroy — Destroy attribute combination list.">igraph_attribute_combination_destroy</a></strong></span>(comb);
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(g);
}
int <span class="strong"><strong>main</strong></span>(void) {
igraph_t g, g2;
igraph_attribute_combination_t comb;
<span class="emphasis"><em>/* Initialize the library. */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_setup" title="4.1. igraph_setup — Initializes the igraph library.">igraph_setup</a></strong></span>();
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_set_attribute_table" title="1.2. igraph_set_attribute_table — Attach an attribute table.">igraph_set_attribute_table</a></strong></span>(&amp;igraph_cattribute_table);
<span class="strong"><strong><a class="link" href="igraph-Generators.html#igraph_small" title="2.2. igraph_small — Shorthand to create a small graph, giving the edges as arguments.">igraph_small</a></strong></span>(&amp;g, 4, IGRAPH_DIRECTED,
0, 1, 0, 1, 0, 1,
1, 2, 2, 3,
-1);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "color", 0, "green");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "color", 1, "red");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "color", 2, "blue");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "color", 3, "white");
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute">SETEAS</a></strong></span>(&amp;g, "color", 4, "black");
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, &amp;g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"weight", IGRAPH_ATTRIBUTE_COMBINE_SUM,
"color", IGRAPH_ATTRIBUTE_COMBINE_FIRST,
"", IGRAPH_ATTRIBUTE_COMBINE_IGNORE,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, &amp;g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"", IGRAPH_ATTRIBUTE_COMBINE_LAST,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_copy" title="5.1.3. igraph_copy — Creates an exact (deep) copy of a graph.">igraph_copy</a></strong></span>(&amp;g2, &amp;g);
<span class="strong"><strong><a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records.">igraph_attribute_combination</a></strong></span>(&amp;comb,
"", IGRAPH_ATTRIBUTE_COMBINE_IGNORE,
"color", IGRAPH_ATTRIBUTE_COMBINE_CONCAT,
IGRAPH_NO_MORE_ATTRIBUTES);
<span class="strong"><strong>simplify_write_destroy</strong></span>(&amp;g2, &amp;comb);
<span class="emphasis"><em>/* ****************************************************** */</em></span>
<span class="strong"><strong><a class="link" href="igraph-Basic.html#igraph_destroy" title="5.1.4. igraph_destroy — Frees the memory allocated for a graph object.">igraph_destroy</a></strong></span>(&amp;g);
<span class="strong"><strong>return</strong></span> 0;
}
</pre>
<p></p>
</div>
</div>
<br class="example-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="query-attributes"></a>4.1. Query attributes</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_list">4.1.1. <code class="function">igraph_cattribute_list</code> — List all attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_has_attr">4.1.2. <code class="function">igraph_cattribute_has_attr</code> — Checks whether a (graph, vertex or edge) attribute exists.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAN">4.1.3. <code class="function">igraph_cattribute_GAN</code> — Query a numeric graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#GAN">4.1.4. <code class="function">GAN</code> — Query a numeric graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAB">4.1.5. <code class="function">igraph_cattribute_GAB</code> — Query a boolean graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#GAB">4.1.6. <code class="function">GAB</code> — Query a boolean graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAS">4.1.7. <code class="function">igraph_cattribute_GAS</code> — Query a string graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#GAS">4.1.8. <code class="function">GAS</code> — Query a string graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAN">4.1.9. <code class="function">igraph_cattribute_VAN</code> — Query a numeric vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VAN">4.1.10. <code class="function">VAN</code> — Query a numeric vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VANV">4.1.11. <code class="function">igraph_cattribute_VANV</code> — Query a numeric vertex attribute for many vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VANV">4.1.12. <code class="function">VANV</code> — Query a numeric vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAB">4.1.13. <code class="function">igraph_cattribute_VAB</code> — Query a boolean vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VAB">4.1.14. <code class="function">VAB</code> — Query a boolean vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VABV">4.1.15. <code class="function">igraph_cattribute_VABV</code> — Query a boolean vertex attribute for many vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VABV">4.1.16. <code class="function">VABV</code> — Query a boolean vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAS">4.1.17. <code class="function">igraph_cattribute_VAS</code> — Query a string vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VAS">4.1.18. <code class="function">VAS</code> — Query a string vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VASV">4.1.19. <code class="function">igraph_cattribute_VASV</code> — Query a string vertex attribute for many vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#VASV">4.1.20. <code class="function">VASV</code> — Query a string vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAN">4.1.21. <code class="function">igraph_cattribute_EAN</code> — Query a numeric edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EAN">4.1.22. <code class="function">EAN</code> — Query a numeric edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EANV">4.1.23. <code class="function">igraph_cattribute_EANV</code> — Query a numeric edge attribute for many edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EANV">4.1.24. <code class="function">EANV</code> — Query a numeric edge attribute for all edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAB">4.1.25. <code class="function">igraph_cattribute_EAB</code> — Query a boolean edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EAB">4.1.26. <code class="function">EAB</code> — Query a boolean edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EABV">4.1.27. <code class="function">igraph_cattribute_EABV</code> — Query a boolean edge attribute for many edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EABV">4.1.28. <code class="function">EABV</code> — Query a boolean edge attribute for all edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAS">4.1.29. <code class="function">igraph_cattribute_EAS</code> — Query a string edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EAS">4.1.30. <code class="function">EAS</code> — Query a string edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EASV">4.1.31. <code class="function">igraph_cattribute_EASV</code> — Query a string edge attribute for many edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#EASV">4.1.32. <code class="function">EASV</code> — Query a string edge attribute for all edges.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_list"></a>4.1.1. <code class="function">igraph_cattribute_list</code> — List all attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_list(const igraph_t *graph,
igraph_strvector_t *gnames, igraph_vector_int_t *gtypes,
igraph_strvector_t *vnames, igraph_vector_int_t *vtypes,
igraph_strvector_t *enames, igraph_vector_int_t *etypes);
</pre></div>
<p>
</p>
<p>
See <a class="link" href="igraph-Attributes.html#igraph_attribute_type_t" title="1.3. igraph_attribute_type_t — The possible types of the attributes."><code class="function">igraph_attribute_type_t</code></a> for the various attribute types.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>gnames</code></em>:</span></p></td>
<td><p>
String vector, the names of the graph attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>gtypes</code></em>:</span></p></td>
<td><p>
Numeric vector, the types of the graph attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vnames</code></em>:</span></p></td>
<td><p>
String vector, the names of the vertex attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vtypes</code></em>:</span></p></td>
<td><p>
Numeric vector, the types of the vertex attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>enames</code></em>:</span></p></td>
<td><p>
String vector, the names of the edge attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>etypes</code></em>:</span></p></td>
<td><p>
Numeric vector, the types of the edge attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Naturally, the string vector with the attribute names and the
numeric vector with the attribute types are in the right order,
i.e. the first name corresponds to the first type, etc.
Time complexity: O(Ag+Av+Ae), the number of all attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_has_attr"></a>4.1.2. <code class="function">igraph_cattribute_has_attr</code> — Checks whether a (graph, vertex or edge) attribute exists.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_bool_t igraph_cattribute_has_attr(const igraph_t *graph,
igraph_attribute_elemtype_t type,
const char *name);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em>:</span></p></td>
<td><p>
The type of the attribute, <code class="constant">IGRAPH_ATTRIBUTE_GRAPH</code>,
<code class="constant">IGRAPH_ATTRIBUTE_VERTEX</code> or <code class="constant">IGRAPH_ATTRIBUTE_EDGE</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Character constant, the name of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Boolean value, <code class="constant">true</code> if the attribute exists, <code class="constant">false</code> otherwise.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(A), the number of (graph, vertex or edge)
attributes, assuming attribute names are not too long.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAN"></a>4.1.3. <code class="function">igraph_cattribute_GAN</code> — Query a numeric graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_real_t igraph_cattribute_GAN(const igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
Returns the value of the given numeric graph attribute.
If the attribute does not exist, a warning is issued
and NaN is returned.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute to query.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#GAN" title="4.1.4. GAN — Query a numeric graph attribute."><code class="function">GAN</code></a> for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Ag), the number of graph attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="GAN"></a>4.1.4. <code class="function">GAN</code> — Query a numeric graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.5.2"></a><p>
</p>
<pre class="programlisting">
#define GAN(graph,n)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAN" title="4.1.3. igraph_cattribute_GAN — Query a numeric graph attribute."><code class="function">igraph_cattribute_GAN()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAB"></a>4.1.5. <code class="function">igraph_cattribute_GAB</code> — Query a boolean graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_bool_t igraph_cattribute_GAB(const igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
Returns the value of the given boolean graph attribute.
If the attribute does not exist, a warning is issued
and false is returned.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute to query.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#GAB" title="4.1.6. GAB — Query a boolean graph attribute."><code class="function">GAB</code></a> for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Ag), the number of graph attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="GAB"></a>4.1.6. <code class="function">GAB</code> — Query a boolean graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.7.2"></a><p>
</p>
<pre class="programlisting">
#define GAB(graph,n)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAB" title="4.1.5. igraph_cattribute_GAB — Query a boolean graph attribute."><code class="function">igraph_cattribute_GAB()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAS"></a>4.1.7. <code class="function">igraph_cattribute_GAS</code> — Query a string graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.8.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
const char *igraph_cattribute_GAS(const igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
Returns a <span class="type">const</span> pointer to the string graph attribute
specified in <em class="parameter"><code>name</code></em>. The value must not be modified.
If the attribute does not exist, a warning is issued and
an empty string is returned.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute to query.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#GAS" title="4.1.8. GAS — Query a string graph attribute."><code class="function">GAS</code></a> for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Ag), the number of graph attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="GAS"></a>4.1.8. <code class="function">GAS</code> — Query a string graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.9.2"></a><p>
</p>
<pre class="programlisting">
#define GAS(graph,n)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAS" title="4.1.7. igraph_cattribute_GAS — Query a string graph attribute."><code class="function">igraph_cattribute_GAS()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAN"></a>4.1.9. <code class="function">igraph_cattribute_VAN</code> — Query a numeric vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.10.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_real_t igraph_cattribute_VAN(const igraph_t *graph, const char *name,
igraph_int_t vid);
</pre></div>
<p>
</p>
<p>
If the attribute does not exist, a warning is issued and
NaN is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_VANV" title="4.1.11. igraph_cattribute_VANV — Query a numeric vertex attribute for many vertices."><code class="function">igraph_cattribute_VANV()</code></a> for
an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
The id of the queried vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#VAN" title="4.1.10. VAN — Query a numeric vertex attribute."><code class="function">VAN</code></a> macro for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Av), the number of vertex attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VAN"></a>4.1.10. <code class="function">VAN</code> — Query a numeric vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.11.2"></a><p>
</p>
<pre class="programlisting">
#define VAN(graph,n,v)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAN" title="4.1.9. igraph_cattribute_VAN — Query a numeric vertex attribute."><code class="function">igraph_cattribute_VAN()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The id of the vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VANV"></a>4.1.11. <code class="function">igraph_cattribute_VANV</code> — Query a numeric vertex attribute for many vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.12.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VANV(const igraph_t *graph, const char *name,
igraph_vs_t vids, igraph_vector_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vids</code></em>:</span></p></td>
<td><p>
The vertices to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(v), where v is the number of vertices in 'vids'.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VANV"></a>4.1.12. <code class="function">VANV</code> — Query a numeric vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.13.2"></a><p>
</p>
<pre class="programlisting">
#define VANV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VANV" title="4.1.11. igraph_cattribute_VANV — Query a numeric vertex attribute for many vertices."><code class="function">igraph_cattribute_VANV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAB"></a>4.1.13. <code class="function">igraph_cattribute_VAB</code> — Query a boolean vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.14.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_bool_t igraph_cattribute_VAB(const igraph_t *graph, const char *name,
igraph_int_t vid);
</pre></div>
<p>
</p>
<p>
If the vertex attribute does not exist, a warning is issued
and false is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_VABV" title="4.1.15. igraph_cattribute_VABV — Query a boolean vertex attribute for many vertices."><code class="function">igraph_cattribute_VABV()</code></a> for
an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
The id of the queried vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#VAB" title="4.1.14. VAB — Query a boolean vertex attribute."><code class="function">VAB</code></a> macro for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Av), the number of vertex attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VAB"></a>4.1.14. <code class="function">VAB</code> — Query a boolean vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.15.2"></a><p>
</p>
<pre class="programlisting">
#define VAB(graph,n,v)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAB" title="4.1.13. igraph_cattribute_VAB — Query a boolean vertex attribute."><code class="function">igraph_cattribute_VAB()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The id of the vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VABV"></a>4.1.15. <code class="function">igraph_cattribute_VABV</code> — Query a boolean vertex attribute for many vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.16.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VABV(const igraph_t *graph, const char *name,
igraph_vs_t vids, igraph_vector_bool_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vids</code></em>:</span></p></td>
<td><p>
The vertices to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized boolean vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(v), where v is the number of vertices in 'vids'.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VABV"></a>4.1.16. <code class="function">VABV</code> — Query a boolean vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.17.2"></a><p>
</p>
<pre class="programlisting">
#define VABV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VABV" title="4.1.15. igraph_cattribute_VABV — Query a boolean vertex attribute for many vertices."><code class="function">igraph_cattribute_VABV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized boolean vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAS"></a>4.1.17. <code class="function">igraph_cattribute_VAS</code> — Query a string vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.18.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
const char *igraph_cattribute_VAS(const igraph_t *graph, const char *name,
igraph_int_t vid);
</pre></div>
<p>
</p>
<p>
Returns a <span class="type">const</span> pointer to the string vertex attribute
specified in <em class="parameter"><code>name</code></em>. The value must not be modified.
If the vertex attribute does not exist, a warning is issued and
an empty string is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_VASV" title="4.1.19. igraph_cattribute_VASV — Query a string vertex attribute for many vertices."><code class="function">igraph_cattribute_VASV()</code></a>
for an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
The id of the queried vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The macro <a class="link" href="igraph-Attributes.html#VAS" title="4.1.18. VAS — Query a string vertex attribute."><code class="function">VAS</code></a> for a simpler interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Av), the number of vertex attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VAS"></a>4.1.18. <code class="function">VAS</code> — Query a string vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.19.2"></a><p>
</p>
<pre class="programlisting">
#define VAS(graph,n,v)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAS" title="4.1.17. igraph_cattribute_VAS — Query a string vertex attribute."><code class="function">igraph_cattribute_VAS()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The id of the vertex.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VASV"></a>4.1.19. <code class="function">igraph_cattribute_VASV</code> — Query a string vertex attribute for many vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.20.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VASV(const igraph_t *graph, const char *name,
igraph_vs_t vids, igraph_strvector_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vids</code></em>:</span></p></td>
<td><p>
The vertices to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized string vector, the result
is stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(v), where v is the number of vertices in 'vids'.
(We assume that the string attributes have a bounded length.)
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="VASV"></a>4.1.20. <code class="function">VASV</code> — Query a string vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.21.2"></a><p>
</p>
<pre class="programlisting">
#define VASV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VASV" title="4.1.19. igraph_cattribute_VASV — Query a string vertex attribute for many vertices."><code class="function">igraph_cattribute_VASV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized string vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAN"></a>4.1.21. <code class="function">igraph_cattribute_EAN</code> — Query a numeric edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.22.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_real_t igraph_cattribute_EAN(const igraph_t *graph, const char *name,
igraph_int_t eid);
</pre></div>
<p>
</p>
<p>
If the attribute does not exist, a warning is issued and
NaN is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_EANV" title="4.1.23. igraph_cattribute_EANV — Query a numeric edge attribute for many edges."><code class="function">igraph_cattribute_EANV()</code></a> for
an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
The id of the queried edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#EAN" title="4.1.22. EAN — Query a numeric edge attribute."><code class="function">EAN</code></a> for an easier interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Ae), the number of edge attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EAN"></a>4.1.22. <code class="function">EAN</code> — Query a numeric edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.23.2"></a><p>
</p>
<pre class="programlisting">
#define EAN(graph,n,e)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAN" title="4.1.21. igraph_cattribute_EAN — Query a numeric edge attribute."><code class="function">igraph_cattribute_EAN()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>e</code></em>:</span></p></td>
<td><p>
The id of the edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EANV"></a>4.1.23. <code class="function">igraph_cattribute_EANV</code> — Query a numeric edge attribute for many edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.24.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EANV(const igraph_t *graph, const char *name,
igraph_es_t eids, igraph_vector_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eids</code></em>:</span></p></td>
<td><p>
The edges to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), where e is the number of edges in 'eids'.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EANV"></a>4.1.24. <code class="function">EANV</code> — Query a numeric edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.25.2"></a><p>
</p>
<pre class="programlisting">
#define EANV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EANV" title="4.1.23. igraph_cattribute_EANV — Query a numeric edge attribute for many edges."><code class="function">igraph_cattribute_EANV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAB"></a>4.1.25. <code class="function">igraph_cattribute_EAB</code> — Query a boolean edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.26.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_bool_t igraph_cattribute_EAB(const igraph_t *graph, const char *name,
igraph_int_t eid);
</pre></div>
<p>
</p>
<p>
If the edge attribute does not exist, a warning is issued and
false is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_EABV" title="4.1.27. igraph_cattribute_EABV — Query a boolean edge attribute for many edges."><code class="function">igraph_cattribute_EABV()</code></a> for
an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
The id of the queried edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#EAB" title="4.1.26. EAB — Query a boolean edge attribute."><code class="function">EAB</code></a> for an easier interface.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(Ae), the number of edge attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EAB"></a>4.1.26. <code class="function">EAB</code> — Query a boolean edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.27.2"></a><p>
</p>
<pre class="programlisting">
#define EAB(graph,n,e)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAB" title="4.1.25. igraph_cattribute_EAB — Query a boolean edge attribute."><code class="function">igraph_cattribute_EAB()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>e</code></em>:</span></p></td>
<td><p>
The id of the edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EABV"></a>4.1.27. <code class="function">igraph_cattribute_EABV</code> — Query a boolean edge attribute for many edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.28.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EABV(const igraph_t *graph, const char *name,
igraph_es_t eids, igraph_vector_bool_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eids</code></em>:</span></p></td>
<td><p>
The edges to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized boolean vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), where e is the number of edges in 'eids'.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EABV"></a>4.1.28. <code class="function">EABV</code> — Query a boolean edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.29.2"></a><p>
</p>
<pre class="programlisting">
#define EABV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EABV" title="4.1.27. igraph_cattribute_EABV — Query a boolean edge attribute for many edges."><code class="function">igraph_cattribute_EABV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAS"></a>4.1.29. <code class="function">igraph_cattribute_EAS</code> — Query a string edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.30.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
const char *igraph_cattribute_EAS(const igraph_t *graph, const char *name,
igraph_int_t eid);
</pre></div>
<p>
</p>
<p>
Returns a <span class="type">const</span> pointer to the string edge attribute
specified in <em class="parameter"><code>name</code></em>. The value must not be modified.
If the edge attribute does not exist, a warning is issued and
an empty string is returned. See <a class="link" href="igraph-Attributes.html#igraph_cattribute_EASV" title="4.1.31. igraph_cattribute_EASV — Query a string edge attribute for many edges."><code class="function">igraph_cattribute_EASV()</code></a> for
an error-checked version.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
The id of the queried edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
\se <a class="link" href="igraph-Attributes.html#EAS" title="4.1.30. EAS — Query a string edge attribute."><code class="function">EAS</code></a> if you want to type less.
Time complexity: O(Ae), the number of edge attributes.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EAS"></a>4.1.30. <code class="function">EAS</code> — Query a string edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.31.2"></a><p>
</p>
<pre class="programlisting">
#define EAS(graph,n,e)
</pre>
<p>
</p>
<p>
This is shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAS" title="4.1.29. igraph_cattribute_EAS — Query a string edge attribute."><code class="function">igraph_cattribute_EAS()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>e</code></em>:</span></p></td>
<td><p>
The id of the edge.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The value of the attribute.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EASV"></a>4.1.31. <code class="function">igraph_cattribute_EASV</code> — Query a string edge attribute for many edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.32.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EASV(const igraph_t *graph, const char *name,
igraph_es_t eids, igraph_strvector_t *result);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eids</code></em>:</span></p></td>
<td><p>
The edges to query.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em>:</span></p></td>
<td><p>
Pointer to an initialized string vector, the result
is stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), where e is the number of edges in
'eids'. (We assume that the string attributes have a bounded length.)
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="EASV"></a>4.1.32. <code class="function">EASV</code> — Query a string edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.11.33.2"></a><p>
</p>
<pre class="programlisting">
#define EASV(graph,n,vec)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EASV" title="4.1.31. igraph_cattribute_EASV — Query a string edge attribute for many edges."><code class="function">igraph_cattribute_EASV()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vec</code></em>:</span></p></td>
<td><p>
Pointer to an initialized string vector, the result is
stored here. It will be resized, if needed.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="set-attributes"></a>4.2. Set attributes</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAN_set">4.2.1. <code class="function">igraph_cattribute_GAN_set</code> — Set a numeric graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETGAN">4.2.2. <code class="function">SETGAN</code> — Set a numeric graph attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAB_set">4.2.3. <code class="function">igraph_cattribute_GAB_set</code> — Set a boolean graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETGAB">4.2.4. <code class="function">SETGAB</code> — Set a boolean graph attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_GAS_set">4.2.5. <code class="function">igraph_cattribute_GAS_set</code> — Set a string graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETGAS">4.2.6. <code class="function">SETGAS</code> — Set a string graph attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAN_set">4.2.7. <code class="function">igraph_cattribute_VAN_set</code> — Set a numeric vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVAN">4.2.8. <code class="function">SETVAN</code> — Set a numeric vertex attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAB_set">4.2.9. <code class="function">igraph_cattribute_VAB_set</code> — Set a boolean vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVAB">4.2.10. <code class="function">SETVAB</code> — Set a boolean vertex attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAS_set">4.2.11. <code class="function">igraph_cattribute_VAS_set</code> — Set a string vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVAS">4.2.12. <code class="function">SETVAS</code> — Set a string vertex attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAN_set">4.2.13. <code class="function">igraph_cattribute_EAN_set</code> — Set a numeric edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEAN">4.2.14. <code class="function">SETEAN</code> — Set a numeric edge attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAB_set">4.2.15. <code class="function">igraph_cattribute_EAB_set</code> — Set a boolean edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEAB">4.2.16. <code class="function">SETEAB</code> — Set a boolean edge attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAS_set">4.2.17. <code class="function">igraph_cattribute_EAS_set</code> — Set a string edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEAS">4.2.18. <code class="function">SETEAS</code> — Set a string edge attribute</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAN_setv">4.2.19. <code class="function">igraph_cattribute_VAN_setv</code> — Set a numeric vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVANV">4.2.20. <code class="function">SETVANV</code> — Set a numeric vertex attribute for all vertices</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAB_setv">4.2.21. <code class="function">igraph_cattribute_VAB_setv</code> — Set a boolean vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVABV">4.2.22. <code class="function">SETVABV</code> — Set a boolean vertex attribute for all vertices</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_VAS_setv">4.2.23. <code class="function">igraph_cattribute_VAS_setv</code> — Set a string vertex attribute for all vertices.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETVASV">4.2.24. <code class="function">SETVASV</code> — Set a string vertex attribute for all vertices</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAN_setv">4.2.25. <code class="function">igraph_cattribute_EAN_setv</code> — Set a numeric edge attribute for all edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEANV">4.2.26. <code class="function">SETEANV</code> — Set a numeric edge attribute for all edges</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAB_setv">4.2.27. <code class="function">igraph_cattribute_EAB_setv</code> — Set a boolean edge attribute for all edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEABV">4.2.28. <code class="function">SETEABV</code> — Set a boolean edge attribute for all edges</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_EAS_setv">4.2.29. <code class="function">igraph_cattribute_EAS_setv</code> — Set a string edge attribute for all edges.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#SETEASV">4.2.30. <code class="function">SETEASV</code> — Set a string edge attribute for all edges</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAN_set"></a>4.2.1. <code class="function">igraph_cattribute_GAN_set</code> — Set a numeric graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_GAN_set(igraph_t *graph, const char *name,
igraph_real_t value);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the graph attribute. If there is no such
attribute yet, then it will be added.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the graph attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
\se <a class="link" href="igraph-Attributes.html#SETGAN" title="4.2.2. SETGAN — Set a numeric graph attribute"><code class="function">SETGAN</code></a> if you want to type less.
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETGAN"></a>4.2.2. <code class="function">SETGAN</code> — Set a numeric graph attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.3.2"></a><p>
</p>
<pre class="programlisting">
#define SETGAN(graph,n,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAN_set" title="4.2.1. igraph_cattribute_GAN_set — Set a numeric graph attribute."><code class="function">igraph_cattribute_GAN_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAB_set"></a>4.2.3. <code class="function">igraph_cattribute_GAB_set</code> — Set a boolean graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_GAB_set(igraph_t *graph, const char *name,
igraph_bool_t value);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the graph attribute. If there is no such
attribute yet, then it will be added.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the graph attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
\se <a class="link" href="igraph-Attributes.html#SETGAN" title="4.2.2. SETGAN — Set a numeric graph attribute"><code class="function">SETGAN</code></a> if you want to type less.
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETGAB"></a>4.2.4. <code class="function">SETGAB</code> — Set a boolean graph attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.5.2"></a><p>
</p>
<pre class="programlisting">
#define SETGAB(graph,n,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAB_set" title="4.2.3. igraph_cattribute_GAB_set — Set a boolean graph attribute."><code class="function">igraph_cattribute_GAB_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_GAS_set"></a>4.2.5. <code class="function">igraph_cattribute_GAS_set</code> — Set a string graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_GAS_set(igraph_t *graph, const char *name,
const char *value);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the graph attribute. If there is no such
attribute yet, then it will be added.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the graph attribute. It will be
copied.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
\se <a class="link" href="igraph-Attributes.html#SETGAS" title="4.2.6. SETGAS — Set a string graph attribute"><code class="function">SETGAS</code></a> if you want to type less.
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETGAS"></a>4.2.6. <code class="function">SETGAS</code> — Set a string graph attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.7.2"></a><p>
</p>
<pre class="programlisting">
#define SETGAS(graph,n,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_GAS_set" title="4.2.5. igraph_cattribute_GAS_set — Set a string graph attribute."><code class="function">igraph_cattribute_GAS_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAN_set"></a>4.2.7. <code class="function">igraph_cattribute_VAN_set</code> — Set a numeric vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.8.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAN_set(igraph_t *graph, const char *name,
igraph_int_t vid, igraph_real_t value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all vertices
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Vertices for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVAN" title="4.2.8. SETVAN — Set a numeric vertex attribute"><code class="function">SETVAN</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices if the attribute is
new, O(|vid|) otherwise.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVAN"></a>4.2.8. <code class="function">SETVAN</code> — Set a numeric vertex attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.9.2"></a><p>
</p>
<pre class="programlisting">
#define SETVAN(graph,n,vid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAN_set" title="4.2.7. igraph_cattribute_VAN_set — Set a numeric vertex attribute."><code class="function">igraph_cattribute_VAN_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Ids of the vertices to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAB_set"></a>4.2.9. <code class="function">igraph_cattribute_VAB_set</code> — Set a boolean vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.10.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAB_set(igraph_t *graph, const char *name,
igraph_int_t vid, igraph_bool_t value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all vertices
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Vertices for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVAB" title="4.2.10. SETVAB — Set a boolean vertex attribute"><code class="function">SETVAB</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices if the attribute is
new, O(|vid|) otherwise.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVAB"></a>4.2.10. <code class="function">SETVAB</code> — Set a boolean vertex attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.11.2"></a><p>
</p>
<pre class="programlisting">
#define SETVAB(graph,n,vid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAB_set" title="4.2.9. igraph_cattribute_VAB_set — Set a boolean vertex attribute."><code class="function">igraph_cattribute_VAB_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Ids of the vertices to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAS_set"></a>4.2.11. <code class="function">igraph_cattribute_VAS_set</code> — Set a string vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.12.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAS_set(igraph_t *graph, const char *name,
igraph_int_t vid, const char *value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all vertices
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Vertices for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVAS" title="4.2.12. SETVAS — Set a string vertex attribute"><code class="function">SETVAS</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n*l), n is the number of vertices, l is the
length of the string to set. If the attribute if not new then only
O(|vid|*l).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVAS"></a>4.2.12. <code class="function">SETVAS</code> — Set a string vertex attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.13.2"></a><p>
</p>
<pre class="programlisting">
#define SETVAS(graph,n,vid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAS_set" title="4.2.11. igraph_cattribute_VAS_set — Set a string vertex attribute."><code class="function">igraph_cattribute_VAS_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>vid</code></em>:</span></p></td>
<td><p>
Ids of the vertices to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAN_set"></a>4.2.13. <code class="function">igraph_cattribute_EAN_set</code> — Set a numeric edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.14.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAN_set(igraph_t *graph, const char *name,
igraph_int_t eid, igraph_real_t value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all edges
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Edges for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEAN" title="4.2.14. SETEAN — Set a numeric edge attribute"><code class="function">SETEAN</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), the number of edges if the attribute is
new, O(|eid|) otherwise.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEAN"></a>4.2.14. <code class="function">SETEAN</code> — Set a numeric edge attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.15.2"></a><p>
</p>
<pre class="programlisting">
#define SETEAN(graph,n,eid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAN_set" title="4.2.13. igraph_cattribute_EAN_set — Set a numeric edge attribute."><code class="function">igraph_cattribute_EAN_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Ids of the edges to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAB_set"></a>4.2.15. <code class="function">igraph_cattribute_EAB_set</code> — Set a boolean edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.16.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAB_set(igraph_t *graph, const char *name,
igraph_int_t eid, igraph_bool_t value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all edges
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Edges for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEAB" title="4.2.16. SETEAB — Set a boolean edge attribute"><code class="function">SETEAB</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), the number of edges if the attribute is
new, O(|eid|) otherwise.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEAB"></a>4.2.16. <code class="function">SETEAB</code> — Set a boolean edge attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.17.2"></a><p>
</p>
<pre class="programlisting">
#define SETEAB(graph,n,eid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAB_set" title="4.2.15. igraph_cattribute_EAB_set — Set a boolean edge attribute."><code class="function">igraph_cattribute_EAB_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Ids of the edges to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAS_set"></a>4.2.17. <code class="function">igraph_cattribute_EAS_set</code> — Set a string edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.18.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAS_set(igraph_t *graph, const char *name,
igraph_int_t eid, const char *value);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present already. If present it
will be overwritten. The same <em class="parameter"><code>value</code></em> is set for all edges
included in <em class="parameter"><code>vid</code></em>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Edges for which to set the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The (new) value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEAS" title="4.2.18. SETEAS — Set a string edge attribute"><code class="function">SETEAS</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e*l), n is the number of edges, l is the
length of the string to set. If the attribute if not new then only
O(|eid|*l).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEAS"></a>4.2.18. <code class="function">SETEAS</code> — Set a string edge attribute</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.19.2"></a><p>
</p>
<pre class="programlisting">
#define SETEAS(graph,n,eid,value)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAS_set" title="4.2.17. igraph_cattribute_EAS_set — Set a string edge attribute."><code class="function">igraph_cattribute_EAS_set()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>eid</code></em>:</span></p></td>
<td><p>
Ids of the edges to set.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em>:</span></p></td>
<td><p>
The new value of the attribute.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAN_setv"></a>4.2.19. <code class="function">igraph_cattribute_VAN_setv</code> — Set a numeric vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.20.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAN_setv(igraph_t *graph, const char *name,
const igraph_vector_t *v);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The new attribute values. The length of this vector must
match the number of vertices.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVANV" title="4.2.20. SETVANV — Set a numeric vertex attribute for all vertices"><code class="function">SETVANV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVANV"></a>4.2.20. <code class="function">SETVANV</code> — Set a numeric vertex attribute for all vertices</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.21.2"></a><p>
</p>
<pre class="programlisting">
#define SETVANV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAN_setv" title="4.2.19. igraph_cattribute_VAN_setv — Set a numeric vertex attribute for all vertices."><code class="function">igraph_cattribute_VAN_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAB_setv"></a>4.2.21. <code class="function">igraph_cattribute_VAB_setv</code> — Set a boolean vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.22.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAB_setv(igraph_t *graph, const char *name,
const igraph_vector_bool_t *v);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The new attribute values. The length of this boolean vector must
match the number of vertices.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVANV" title="4.2.20. SETVANV — Set a numeric vertex attribute for all vertices"><code class="function">SETVANV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVABV"></a>4.2.22. <code class="function">SETVABV</code> — Set a boolean vertex attribute for all vertices</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.23.2"></a><p>
</p>
<pre class="programlisting">
#define SETVABV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAB_setv" title="4.2.21. igraph_cattribute_VAB_setv — Set a boolean vertex attribute for all vertices."><code class="function">igraph_cattribute_VAB_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_VAS_setv"></a>4.2.23. <code class="function">igraph_cattribute_VAS_setv</code> — Set a string vertex attribute for all vertices.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.24.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_VAS_setv(igraph_t *graph, const char *name,
const igraph_strvector_t *sv);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>sv</code></em>:</span></p></td>
<td><p>
String vector, the new attribute values. The length of this vector must
match the number of vertices.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETVASV" title="4.2.24. SETVASV — Set a string vertex attribute for all vertices"><code class="function">SETVASV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n+l), n is the number of vertices, l is the
total length of the strings.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETVASV"></a>4.2.24. <code class="function">SETVASV</code> — Set a string vertex attribute for all vertices</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.25.2"></a><p>
</p>
<pre class="programlisting">
#define SETVASV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_VAS_setv" title="4.2.23. igraph_cattribute_VAS_setv — Set a string vertex attribute for all vertices."><code class="function">igraph_cattribute_VAS_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAN_setv"></a>4.2.25. <code class="function">igraph_cattribute_EAN_setv</code> — Set a numeric edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.26.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAN_setv(igraph_t *graph, const char *name,
const igraph_vector_t *v);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The new attribute values. The length of this vector must
match the number of edges.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEANV" title="4.2.26. SETEANV — Set a numeric edge attribute for all edges"><code class="function">SETEANV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), the number of edges.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEANV"></a>4.2.26. <code class="function">SETEANV</code> — Set a numeric edge attribute for all edges</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.27.2"></a><p>
</p>
<pre class="programlisting">
#define SETEANV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAN_setv" title="4.2.25. igraph_cattribute_EAN_setv — Set a numeric edge attribute for all edges."><code class="function">igraph_cattribute_EAN_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAB_setv"></a>4.2.27. <code class="function">igraph_cattribute_EAB_setv</code> — Set a boolean edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.28.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAB_setv(igraph_t *graph, const char *name,
const igraph_vector_bool_t *v);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
The new attribute values. The length of this vector must
match the number of edges.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEABV" title="4.2.28. SETEABV — Set a boolean edge attribute for all edges"><code class="function">SETEABV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e), the number of edges.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEABV"></a>4.2.28. <code class="function">SETEABV</code> — Set a boolean edge attribute for all edges</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.29.2"></a><p>
</p>
<pre class="programlisting">
#define SETEABV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAB_setv" title="4.2.27. igraph_cattribute_EAB_setv — Set a boolean edge attribute for all edges."><code class="function">igraph_cattribute_EAB_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_EAS_setv"></a>4.2.29. <code class="function">igraph_cattribute_EAS_setv</code> — Set a string edge attribute for all edges.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.30.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_cattribute_EAS_setv(igraph_t *graph, const char *name,
const igraph_strvector_t *sv);
</pre></div>
<p>
</p>
<p>
The attribute will be added if not present yet.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>sv</code></em>:</span></p></td>
<td><p>
String vector, the new attribute values. The length of this vector must
match the number of edges.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#SETEASV" title="4.2.30. SETEASV — Set a string edge attribute for all edges"><code class="function">SETEASV</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(e+l), e is the number of edges, l is the
total length of the strings.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="SETEASV"></a>4.2.30. <code class="function">SETEASV</code> — Set a string edge attribute for all edges</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.12.31.2"></a><p>
</p>
<pre class="programlisting">
#define SETEASV(graph,n,v)
</pre>
<p>
</p>
<p>
This is a shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_EAS_setv" title="4.2.29. igraph_cattribute_EAS_setv — Set a string edge attribute for all edges."><code class="function">igraph_cattribute_EAS_setv()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Vector containing the new values of the attributes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="remove-attributes"></a>4.3. Remove attributes</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_remove_g">4.3.1. <code class="function">igraph_cattribute_remove_g</code> — Remove a graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELGA">4.3.2. <code class="function">DELGA</code> — Remove a graph attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_remove_v">4.3.3. <code class="function">igraph_cattribute_remove_v</code> — Remove a vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELVA">4.3.4. <code class="function">DELVA</code> — Remove a vertex attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_remove_e">4.3.5. <code class="function">igraph_cattribute_remove_e</code> — Remove an edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELEA">4.3.6. <code class="function">DELEA</code> — Remove an edge attribute.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#igraph_cattribute_remove_all">4.3.7. <code class="function">igraph_cattribute_remove_all</code> — Remove all graph/vertex/edge attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELGAS">4.3.8. <code class="function">DELGAS</code> — Remove all graph attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELVAS">4.3.9. <code class="function">DELVAS</code> — Remove all vertex attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELEAS">4.3.10. <code class="function">DELEAS</code> — Remove all edge attributes.</a></span></dt>
<dt><span class="section"><a href="igraph-Attributes.html#DELALL">4.3.11. <code class="function">DELALL</code> — Remove all attributes.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_remove_g"></a>4.3.1. <code class="function">igraph_cattribute_remove_g</code> — Remove a graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_cattribute_remove_g(igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph object.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the graph attribute to remove.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#DELGA" title="4.3.2. DELGA — Remove a graph attribute."><code class="function">DELGA</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELGA"></a>4.3.2. <code class="function">DELGA</code> — Remove a graph attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.3.2"></a><p>
</p>
<pre class="programlisting">
#define DELGA(graph,n)
</pre>
<p>
</p>
<p>
A shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_g" title="4.3.1. igraph_cattribute_remove_g — Remove a graph attribute."><code class="function">igraph_cattribute_remove_g()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute to remove.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_remove_v"></a>4.3.3. <code class="function">igraph_cattribute_remove_v</code> — Remove a vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_cattribute_remove_v(igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph object.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the vertex attribute to remove.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#DELVA" title="4.3.4. DELVA — Remove a vertex attribute."><code class="function">DELVA</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELVA"></a>4.3.4. <code class="function">DELVA</code> — Remove a vertex attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.5.2"></a><p>
</p>
<pre class="programlisting">
#define DELVA(graph,n)
</pre>
<p>
</p>
<p>
A shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_v" title="4.3.3. igraph_cattribute_remove_v — Remove a vertex attribute."><code class="function">igraph_cattribute_remove_v()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute to remove.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_remove_e"></a>4.3.5. <code class="function">igraph_cattribute_remove_e</code> — Remove an edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_cattribute_remove_e(igraph_t *graph, const char *name);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph object.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>:</span></p></td>
<td><p>
Name of the edge attribute to remove.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#DELEA" title="4.3.6. DELEA — Remove an edge attribute."><code class="function">DELEA</code></a> for a simpler way.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELEA"></a>4.3.6. <code class="function">DELEA</code> — Remove an edge attribute.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.7.2"></a><p>
</p>
<pre class="programlisting">
#define DELEA(graph,n)
</pre>
<p>
</p>
<p>
A shorthand for <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_e" title="4.3.5. igraph_cattribute_remove_e — Remove an edge attribute."><code class="function">igraph_cattribute_remove_e()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The name of the attribute to remove.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="igraph_cattribute_remove_all"></a>4.3.7. <code class="function">igraph_cattribute_remove_all</code> — Remove all graph/vertex/edge attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.8.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_cattribute_remove_all(igraph_t *graph, igraph_bool_t g,
igraph_bool_t v, igraph_bool_t e);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph object.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>g</code></em>:</span></p></td>
<td><p>
Boolean, whether to remove graph attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em>:</span></p></td>
<td><p>
Boolean, whether to remove vertex attributes.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>e</code></em>:</span></p></td>
<td><p>
Boolean, whether to remove edge attributes.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>See also: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
<a class="link" href="igraph-Attributes.html#DELGAS" title="4.3.8. DELGAS — Remove all graph attributes."><code class="function">DELGAS</code></a>, <a class="link" href="igraph-Attributes.html#DELVAS" title="4.3.9. DELVAS — Remove all vertex attributes."><code class="function">DELVAS</code></a>, <a class="link" href="igraph-Attributes.html#DELEAS" title="4.3.10. DELEAS — Remove all edge attributes."><code class="function">DELEAS</code></a>, <a class="link" href="igraph-Attributes.html#DELALL" title="4.3.11. DELALL — Remove all attributes."><code class="function">DELALL</code></a> for simpler
ways.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELGAS"></a>4.3.8. <code class="function">DELGAS</code> — Remove all graph attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.9.2"></a><p>
</p>
<pre class="programlisting">
#define DELGAS(graph)
</pre>
<p>
</p>
<p>
Calls <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_all" title="4.3.7. igraph_cattribute_remove_all — Remove all graph/vertex/edge attributes."><code class="function">igraph_cattribute_remove_all()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELVAS"></a>4.3.9. <code class="function">DELVAS</code> — Remove all vertex attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.10.2"></a><p>
</p>
<pre class="programlisting">
#define DELVAS(graph)
</pre>
<p>
</p>
<p>
Calls <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_all" title="4.3.7. igraph_cattribute_remove_all — Remove all graph/vertex/edge attributes."><code class="function">igraph_cattribute_remove_all()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELEAS"></a>4.3.10. <code class="function">DELEAS</code> — Remove all edge attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.11.2"></a><p>
</p>
<pre class="programlisting">
#define DELEAS(graph)
</pre>
<p>
</p>
<p>
Calls <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_all" title="4.3.7. igraph_cattribute_remove_all — Remove all graph/vertex/edge attributes."><code class="function">igraph_cattribute_remove_all()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="DELALL"></a>4.3.11. <code class="function">DELALL</code> — Remove all attributes.</h4></div></div></div>
<a class="indexterm" name="id-1.11.8.13.12.2"></a><p>
</p>
<pre class="programlisting">
#define DELALL(graph)
</pre>
<p>
</p>
<p>
All graph, vertex and edges attributes will be removed.
Calls <a class="link" href="igraph-Attributes.html#igraph_cattribute_remove_all" title="4.3.7. igraph_cattribute_remove_all — Remove all graph/vertex/edge attributes."><code class="function">igraph_cattribute_remove_all()</code></a>.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The graph.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="c-attribute-combination-functions"></a>4.4. Custom attribute combination functions</h3></div></div></div>
<p>
The C attribute handler supports combining the attributes of multiple
vertices of edges into a single attribute during a vertex or edge contraction
operation via a user-defined function. This is achieved by setting the
type of the attribute combination to <code class="constant">IGRAPH_ATTRIBUTE_COMBINE_FUNCTION</code>
and passing in a pointer to the custom combination function when specifying
attribute combinations in <a class="link" href="igraph-Attributes.html#igraph_attribute_combination" title="3.6. igraph_attribute_combination — Initialize attribute combination list and add records."><code class="function">igraph_attribute_combination()</code></a> or
<a class="link" href="igraph-Attributes.html#igraph_attribute_combination_add" title="3.2. igraph_attribute_combination_add — Add combination record to attribute combination list."><code class="function">igraph_attribute_combination_add()</code></a> . For the C attribute handler, the
signature of the function depends on the type of the underlying attribute.
For numeric attributes, use:
</p>
<div class="informalexample"><pre class="programlisting"> igraph_error_t function(const igraph_vector_t *input, igraph_real_t *output); </pre></div>
<p>
where <em class="parameter"><code>input</code></em> will receive a vector containing the value of the attribute
for all the vertices or edges being combined, and <em class="parameter"><code>output</code></em> must be filled
by the function to the combined value. Similarly, for Boolean attributes, the
function takes a boolean vector in <em class="parameter"><code>input</code></em> and must return the combined Boolean
value in <em class="parameter"><code>output</code></em>:
</p>
<div class="informalexample"><pre class="programlisting"> igraph_error_t function(const igraph_vector_bool_t *input, igraph_bool_t *output); </pre></div>
<p>
For string attributes, the signature is slightly different:
</p>
<div class="informalexample"><pre class="programlisting"> igraph_error_t function(const igraph_strvector_t *input, char **output); </pre></div>
<p>
In case of strings, all strings in the input vector are <span class="emphasis"><em>owned</em></span> by igraph
and must not be modified or freed in the combination handler. The string
returned to the caller in <em class="parameter"><code>output</code></em> remains owned by the caller; igraph will
make a copy it and store the copy in the appropriate part of the data
structure holding the vertex or edge attributes.
</p>
</div>
</div>
</div>
<table class="navigation-footer" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle">
<td align="left"><a accesskey="p" href="igraph-Iterators.html"><b>← Chapter 9. Vertex and edge selectors and sequences, iterators</b></a></td>
<td align="right"><a accesskey="n" href="igraph-Generators.html"><b>Chapter 11. Deterministic graph generators →</b></a></td>
</tr></table>
</body>
</html>