| igraph Reference Manual |
|---|
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 are 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 number 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),
(2,3),
(3,3),
(3,4),
(3,4),
(4,1)
}
)
Here the edges are ordered pairs or vertex ids, and the graph is a multiset of edges plus some meta-data.
An undirected graph is like this:
( vertices: 6,
directed: no,
{
{0,2},
{2},
{2,3},
{3},
{3,4},
{3,4},
{4,1}
}
)
Here an edge is a set of one or two vertex ids, two for most of the time, except for loop edges. A graph is a multiset of edges plus meta data, just like in the directed case.
It is possible to convert a directed graph to an undirected one,
see the
igraph_to_directed()
and
igraph_to_undirected() functions.
Note that igraph has some limited support for
graphs with multiple edges. The support means that multiple edges can
be stored in igraph graphs, but for most functions
(like
igraph_betweenness()) it is not checked
that they work well on graphs with multiple edges.
To eliminate multiple edges from a graph, you can use
igraph_simplify().
| << Chapter 4. About igraph graphs, the basic interface | 2. The basic interface >> |