]> About &igraph; graphs, the basic interface
The &igraph; data model The &igraph; library can handle directed and undirected graphs. The &igraph; graphs are multisets of ordered (if directed) or unordered (if undirected) labeled pairs. The labels of the pairs plus the number of vertices always starts with zero and ends with the number of edges minus one. In addition to that a table of metadata is also attached to every graph, its most important entries being the number of vertices in the graph and whether the graph is directed or undirected. Like the edges, the &igraph; vertices are also labeled by numbers between zero and the number of vertices minus one. So, to summarize, a directed graph can be imagined like this: ( vertices: 6, directed: yes, { (0,2), (2,2), (3,2), (3,3), (3,4), (3,4), (4,3), (4,1) } ) Here the edges are ordered pairs or vertex ids, and the graph is a multiset of edges plus some metadata. An undirected graph is like this: ( vertices: 6, directed: no, { (0,2), (2,2), (2,3), (3,3), (3,4), (3,4), (3,4), (1,4) } ) Here, an edge is an unordered pair of two vertex ids. A graph is a multiset of edges plus metadata, just like in the directed case. It is possible to convert between directed and undirected graphs, see the igraph_to_directed() and igraph_to_undirected() functions. &igraph; aims to robustly support multigraphs, i.e. graphs which have more than one edge between some pairs of vertices, as well as graphs with self-loops. Most functions which do not support such graphs will check their input and issue an error if it is not valid. Those rare functions which do not perform this check clearly indicate this in their documentation. To eliminate multiple edges from a graph, you can use igraph_simplify().
About &igraph; functions &igraph; has a simple and consistent interface. Most functions check their input for validity and display an informative error message when something goes wrong. In order to support this, the majority of functions return an error code. In basic usage, this code can be ignored, as the default behaviour is to abort the program immediately upon error. See the section on error handling for more information on this topic. Results are typically returned through output arguments, i.e. pointers to a data structure into which the result will be written. In almost all cases, this data structure is expected to be pre-initialized. A few simple functions communicate their result directly through their return value—these functions can never encounter an error.
The basic interface
Graph constructors and destructors
Basic query operations
Adding and deleting vertices and edges