Update, spring 2016: To access igraph from Mathematica, I recommend using IGraph/M instead of IGraphR when it has the functions you need. IGraphR is no longer being developed.
Call igraph with ease from Mathematica through RLink. RLink is available in Mathematica 9 or later.
See a short IGraphR tutorial here.
Easy automatic install:
Just evaluate Get["https://raw.githubusercontent.com/szhorvat/IGraphR/master/install.m"]
. It will install into $UserBaseDirectory
and overwrite any old versions there.
Manual installation:
Download IGraphR.m
and drop it into the directory opened by this command:
SystemOpen@FileNameJoin[{$UserBaseDirectory, "Applications"}]
First, make sure that you are using an R installation that has the igraph package.
On Windows, you can simply install it into Mathematica's internal R like this:
REvaluate["install.packages('igraph')"]
On OS X and Linux it is necessary to use an external R installation. See this guide on how to do that. Run the R version you are using outside of Mathematica and run install.packages('igraph')
to install the igraph package into it.
Now you are ready to load IGraphR`
in Mathematica:
Needs["IGraphR`"]
In[]:= IGraph["vertex.connectivity"][CycleGraph[5]]
Out[]= {2.}
In[]:= IGraph["barabasi.game"][10]
Out[]= --Graph--
In[]:= IGraph["plot"][Graph[{a <-> b, b <-> c}]]
Mathematica 10 supports mixed graphs which have both directed and undirected edges. These are not supported by igraph or IGraphR.
If you encounter any problems with IGraphR, send a mail to szhorvat
at gmail.com
.
This package is provided under the MIT license. See LICENSE.txt
for details.