Main packages in the SNA4DS course
Overview of igraph and network graph
objects
There are two main packages for basic graph generation and
manipulation: the igraph package and the
statnet package. Actually, statnet is a suite
of packages that work together. In this course, we will will make use of
several packages from the statnet suite.
The igraph package creates a graph object of type
igraph. The statnet suite creates a graph
object of type network. There are many things you can do in
both packages. Both packages can generate graphs and do basic
manipulation, so here you should just use the package whose API you like
best. The igraph package provides more mathematical
functions to apply to the graph data and the statnet suite
provides loads of statistical models that the igraph
package does not do.
The snafun package
The igraph package and statnet suite are
jointly very powerful and can support much of your analyses of network
data. However, as you read above, they each require graph objects that
have specific structures and they can’t deal with a graph object that
has a different structure. So, if you want to use the functions from
both the igraph and the sna packages, you need
network data in igraph format (for the igraph
package), in network format (for the network
package and some of the sna package) and in
matrix format (for many of the functions in the
sna package). In other words, you will have to convert your
data between these formats and you also have to deal with the differing
API’s between these various packages.
Believe it or not, this is a pain and quite annoying.
THE snafun PACKAGE TO THE RESCUE!
The snafun package does three things:
- First, it provides an (fairly) consistent API, so you don’t have to constantly figure out what a specific argument means for each function;
- Second, most of the functions in the
snafunpackage work on both objects of classigraphornetwork. As a result, you can do what you want to do, without bothering with whether the object you work on is of classigraphornetwork. - Third, by removing the pain coming from the constant switching between the two groups of packages and their inconsistent API, you can now actually focus on the fun of network analysis, rather than the frustration.
Oh, and there is a fourth advantage too: the authors of the
snafun package are cool people. So, if you have the need
for a new function in the package, just get in touch with us and we’ll
see what we can do for you.
:-)