Chapter 12. Graph, Vertex and Edge Attributes

1. The Attribute Handler Interface
2. Accessing attributes from C

Attributes are numbers or strings (or basically any kind of data) associated with the vertices or edges of a graph, or with the graph itself. Eg. you may label vertices with symbolic names or attach numeric weights to the edges of a graph.

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 GNU R all R types are allowed. There is an experimental attribute implementation to be used when programming in C, but by default it is currently turned off.

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.