The IGraph/M package provides a Mathematica interface to the popular igraph network analysis and graph theory package, as well as many other functions for working with graphs in Mathematica. Check out the blog post for an overview.
First, note that the system requirements are Mathematica 10.0.2 or later, 64-bit Windows/macOS/Linux, or Raspberry Pi.
The simplest way to install automatically from the internet is to evaluate the following line in Mathematica:
Get["https://raw.githubusercontent.com/szhorvat/IGraphM/master/IGInstaller.m"]
IGraph/M can also be installed manually in the same way as any Mathematica application distributed as a paclet.
Download the .paclet
file from the GitHub releases page, and install it using the PacletInstall
function in Mathematica. For example, assuming that the file IGraphM-0.3.112.paclet
was downloaded into the directory ~/Downloads
, evaluate
Needs["PacletManager`"]
PacletInstall["~/Downloads/IGraphM-0.3.112.paclet"]
IGraph/M requires Mathematica 10.0.2 or later. Binaries are included for Windows 64-bit, OS X 10.9 or later, Linux x86_64 and Raspbian (Linux ARM on Raspberry Pi). For other operating systems the package must be compiled from source (see Development.md for guidance).
After installation, the package can now be loaded with
<< IGraphM`
Check that it works by evaluating IGVersion[]
, then continue to the documentation with IGDocumentation[]
.
To uninstall all currently installed versions of IGraph/M, evaluate PacletUninstall["IGraphM]
. This will remove all traces of IGraph/M from your system.
To open the documentation notebook, evaluate
Needs["IGraphM`"]
IGDocumentation[]
or search for "igraphm" in Mathematica's Documentation Center.
The documentation is not yet complete and contributions are very welcome. If you would like to help out with expanding the documentation, send me an email.
For additional details about functions, or for paper references for the methods used, also check the igraph documentation pages.
Update: Help wanted with editing documentation and writing unit tests! Only basic Mathematica knowledge is required for this.
Contributions to IGraph/M are very welcome! Mathematica programmers of all levels of expertise can contribute.
In order of increasing difficulty, help is needed with the following tasks:
- Just test the package and try to find problems.
- Create examples for the documentation or edit the documentation.
- Write formal unit tests.
- Implement new functions in pure Wolfram Language code.
- Expose more igraph library functions to IGraph/M (C++ knowledge required)
- Implement entirely new functions in C++.
If you are interested in contributing, send me an email for guidance. Evaluate the following in Mathematica to get my email address:
Uncompress["1:eJxTTMoPChZiYGAorsrILypLLHFIz03MzNFLzs8FAG/xCOI="]
C++ programmers should look at Development.md for additional information.
IGraph/M is currently under development, and a few bugs are to be expected. However, I try not to release a new version until most problems I know of are fixed. If you do find a problem, please open an issue on GitHub or write in the chatroom. In the bug report include the output of IGraphM`Developer`GetInfo[]
.
-
"Cannot open
IGraphM`
"This message will be shown in the following situations:
-
IGraph/M is not installed. Please follow the installation instructions above carefully.
-
IGraph/M is not compatible with your system. Please review the requirements in the Installation section above. Additional symptoms will be that
PacletFind["IGraphM"]
returns{}
butPacletFind["IGraphM", "MathematicaVersion" -> All, "SystemID" -> All]
returns a non-empty list.
-
-
"Cannot open
LTemplate`LTemplatePrivate`
"Loading fails with this error if one tries to use the
master
branch (development branch) without the necessary dependencies.Please download IGraph/M from the GitHub releases page instead. It includes everything needed to run the package.
Do not clone the git repository and do not use the
master
branch unless you want to develop IGraph/M. -
"No build settings found. Please check
BuildSettings.m
"This error may be shown when trying to load IGraph/M on an incompatible platform. Currently, the following platforms are supported: Windows 64-bit, OS X 10.9 or later, Linux x86_64 with glibc 2.14 or later, Raspberry Pi with Raspbian Stretch.
It may be possible to run IGraph/M on other platforms, however, it will be necessary to compile it from source.
If you see this error on a supported platform, please file a bug report and include the output of
IGraphM`Developer`GetInfo[]
. -
The function IGlobal_get_collection was not loaded from the file ...
or similar error appears on LinuxCheck that you are using a Linux distribution with glibc 2.14 or later. This is the minimum requirement. If your Linux distribution does have the required glibc version, then please open a new issue.
-
Graph[Graph[...], ...]
is returnedSometimes layout functions may return an expression which looks like
Graph[ Graph[...], VertexCoordinates -> {...} ]
or similar. A property does not get correctly applied to the graph. This is due to a bug in Mathematica. I believe I have worked around most of these issues, but if you encounter them, one possible workaround is to cycle the graph
g
through some other representation, e.g.g = Uncompress@Compress[g]
. -
The graphs returned by
IGBipartiteGameGNM
andIGBipartiteGameGNP
may not render when using theDirectedEdges -> True
and"Bidirectional" -> True
options. This is due to a bug in Mathematica's"BipartiteEmbedding"
graph layout and can be corrected by passingGraphLayout -> Automatic
to these functions. Alternatively, they may be rendered usingIGLayoutBipartite
. -
LAD functions may crash with certain inputs. This is a bug in the igraph C core.
-
IGDocumentation[]
may not work with Mathematica 11.1 on Linux. Please enterIGraphM/IGDocumentation
in the Documentation Center address bar to access it (or simply search forigraph
in the Documentation Center). -
IGZeroDiagonal
will crash with non-square sparse matrices in Mathematica 11.1 and earlier. This is a bug in those versions of Mathematica. -
When loading IGraph/M in Mathematica 10.0 on recent versions of macOS (e.g. Mojave), the front end might crash. This is a problem specific to Mathematica 10.0, and, as far as I am aware, does not occur with newer versions. If this problem affects you, load IGraph/M as
Block[{Print}, Needs["IGraphM`"]]
.
New functions in this release:
- Deterministic graph generators:
IGKautzGraph
,IGCompleteGraph
,IGCompleteAcyclicGraph
,IGDeBruijnGraph
,IGChordalRing
,IGEmptyGraph
,IGRealizeDegreeSequence
,IGFromPrufer
,IGToPrufer
,IGKaryTree
,IGSymmetricTree
,IGBetheLattice
,IGTriangularLattice
,IGMycielskian
,IGExpressionTree
,IGShorthand
. - Random graph generators:
IGWattsStrogatzGame
,IGCallawayTraitsGame
,IGEstablishmentGame
,IGTreeGame
,IGErdosRenyiGameGNM
,IGErdosRenyiGameGNP
. - Weighted graph functions:
IGWeightedSimpleGraph
,IGWeightedUndirectedGraph
,IGWeightedVertexDelete
,IGWeightedSubgraph
,IGUnweighted
,IGDistanceWeighted
,IGWeightedAdjacencyGraph
,IGVertexWeightedQ
,IGEdgeWeightedQ
,IGVertexStrength
,IGVertexInStrength
,IGVertexOutStrength
. - Graph colouring functions:
IGVertexColoring
,IGEdgeColoring
,IGKVertexColoring
,IGKEdgeColoring
,IGMinimumVertexColoring
,IGMinimumEdgeColoring
,IGChromaticNumber
,IGChromaticIndex
,IGVertexColoringQ
. - Clique cover:
IGCliqueCover
,IGCliqueCoverNumber
. - Mesh/graph conversion:
IGMeshGraph
,IGMeshCellAdjacencyMatrix
,IGMeshCellAdjacencyGraph
. - Lattice generation:
IGLatticeMesh
,IGTriangularLattice
. - Proximity graphs:
IGDelaunayGraph
,IGGabrielGraph
,IGRelativeNeighborhoodGraph
,IGLuneBetaSkeleton
,IGCircleBetaSkeleton
. - Centralization:
IGDegreeCentralization
,IGBetweennessCentralization
,IGClosenessCentralization
,IGEigenvectorCentralization
. - Planar graphs:
IGPlanarQ
,IGMaximalPlanarQ
,IGOuterplanarQ
,IGKuratowskiEdges
,IGFaces
,IGDualGraph
,IGEmbeddingQ
,IGPlanarEmbedding
,IGOuterplanarEmbedding
,IGCoordinatesToEmbedding
,IGEmbeddingToCoordinates
,IGLayoutPlanar
,IGLayoutTutte
. - Spanning trees and other tree-related functionality:
IGSpanningTree
,IGRandomSpanningTree
,IGSpanningTreeCount
,IGUnfoldTree
,IGTreeQ
,IGForestQ
,IGTreelikeComponents
,IGTreeGame
,IGStrahlerNumber
,IGOrientTree
. - Matching functions:
IGMaximumMatching
,IGMatchingNumber
. - Dominance:
IGDominatorTree
,IGImmediateDominators
- Maximum flow:
IGMaximumFlowValue
,IGMaximumFlowMatrix
. - Isomorphism:
IGGetIsomorphism
andIGGetSubisomorphism
(they work with multigraphs),IGColoredSimpleGraph
(for transforming multigraph isomorphism to coloured graph isomorphism). - Transitivity:
IGVertexTransitiveQ
,IGEdgeTransitiveQ
,IGSymmetricQ
,IGDistanceTransitiveQ
. - Regular graphs:
IGRegularQ
,IGStronglyRegularQ
,IGStronglyRegularParameters
,IGDistanceRegularQ
,IGIntersectonArray
. - A framework for easy property transformations and graph styling:
IGVertexProp
,IGEdgeProp
,IGEdgeVertexProp
,IGVertexMap
,IGEdgeMap
,IGVertexPropertyList
,IGEdgePropertyList
. - Export functions:
IGExport
,IGExportString
,$IGExportFormats
; support for exporting standards-compliant GraphML that can be read by other igraph interfaces (R, Python). - Matrix functions:
IGZeroDiagonal
,IGTakeUpper
,IGTakeLower
,IGAdjacencyMatrixPlot
,IGKirchhoffMatrix
,IGJointDegreeMatrix
- Added
IGIndexEdgeList
for retrieving the edge list of a graph in terms of vertex indices. This function is very fast and returns a packed array. It facilitates the efficient implementation of graph processing functions in pure Mathematica code, or interfacing with C libraries. - Bipartite graphs:
IGBipartiteIncidenceMatrix
,IGBipartiteIncidenceGraph
,IGBipartiteProjections
- Random walks:
IGRandomEdgeWalk
,IGRandomEdgeIndexWalk
- Connectivity:
IGGiantComponent
,IGMinimalSeparators
,IGBridges
,IGConnectedComponentSizes
,IGWeaklyConnectedComponentSizes
,IGGomoryHuTree
- Other testing functions:
IGTriangleFreeQ
,IGSelfComplementaryQ
,IGCactusQ
,IGNullGraphQ
,IGHomeomorphicQ
. - Other new functions:
IGNeighborhoodSize
,IGCoreness
,IGVoronoiCells
,IGSmoothen
,IGSimpleGraph
,IGPartitionsToMembership
,IGMembershipToPartitions
,IGSinkVertexList
,IGSourceVertexList
,IGIsolatedVertexList
,IGReorderVertices
,IGTakeSubgraph
,IGDisjointUnion
,IGAdjacencyList
,IGAdjacencyGraph
.
Updates to existing functions:
- Community detection: Several functions support the
"ClusterCount"
option now; addedIGCommunitiesFluid
. IGRewireEdges
now supports rewiring only the start or endpoint of directed edges (instead of both).IGBipartiteQ
now supports checking that a given partitioning is valid for a bipartite graph.IGBipartitePartitions
now provides control over the ordering of partitions using its second argument.- Isomorphism functions now ignore the directedness of empty graphs.
- Isomorphism functions can now take vertex or edge colours from graph attributes.
IGBlissCanonicalGraph
will now include include vertex colours into its output when appropriate, encoded as the"Color"
vertex property.IGDistanceCounts
now optionally takes a list of starting vertices.IGBetweenness(Estimate)
andIGCloseness(Estimate)
now optionally take a set of vertices to do the calculation on.IGBetweenness(Estimate)
andIGEdgeBetweenness(Estimate)
now have theNormalized
option.IGRandomWalk
now supports edge weights and theEdgeWeights
option. UseEdgeWeights -> None
to ignore weights, and thus restore the previous behaviour.- Clustering coefficient functions now support the
"ExcludeIsolates"
option.
Incompatible changes from IGraph/M 0.3:
- A flat namespace structure is used. Functions from
IGraphM`Utilities`
have been moved toIGraphM`
. - Renamed
"MultipleEdges"
option toMultiEdges
for convenient typing and auto-completion. - Renamed
IGMinSeparators
toIGMinimumSeparators
. - Renamed
IGMakeLattice
toIGSquareLattice
. The nameIGMakeLattice
works, but it is deprecated. - Removed graphlet functions due to a long-time unresolved bug in the igraph C core.
Other changes:
- Improved compatibility with Mathematica 11.2, 11.3 and 12.0; handling of
TwoWayRule
as an edge specification. - Bug fixes, performance improvements, documentation updates, and general polish.
Notes:
- IGraph/M 0.4 will be the last version of IGraph/M to support Mathematica 10.0. Starting with IGraph/M 0.5, it will only work with versions of Mathematica that are still supported by Wolfram Research.
- Compatibility with Mathematica 11.1.
- Additional random graph generators (
IGBarabasiAlbertGame
,IGStaticFitnessGame
,IGStaticPowerLawGame
,IGGeometricGame
,IGGrowingGame
,IGForestFireGame
). - Bipartite graph layout,
IGLayoutBipartite
. - Performance improvements in
IGMaximalCliqueSizeCounts
. IGEccentricity
andIGRadius
.IGVertexContract
, to contract multiple vertex sets simultaneously.IGRandomWalk
, to take a random walk on a graph.IGraphM`Utilities`
package.- Significantly improved package loading performance.
- Bug fixes and polish.
This is a bugfix release with several minor fixes. Important changes to be aware of:
- VF2 isomorphism functions now work when both vertex and edge colours are specified at the same time.
IGBlissCanonicalGraph
is now suitable for filtering isomorphic duplicates. Its output may be different from previous releases.
This is a bugfix release. The following changes require special mention:
IGFeedbackArcSet
could return wrong results for some graphs. This is now fixed.- The
"RemovedEdges"
property returned byIGCommunitiesEdgeBetweenness
could be incorrect for some graphs. This is now fixed. Other properties were not affected. - The Hierarchical Clustering package is no longer auto-loaded by IGraph/M to avoid shadowing
DistanceMatrix
, a new built-in function added in Mathematica 10.3. Load this package manually (<<HierarchicalClustering`
) to work with the"HierarchicalClusters"
property ofIGClusterData
objects.
A number of other small bugs were also fixed.
- Significant performance improvements for many functions
- New and extended functions for shortest path calculations (extended
IGDistanceMatrix
,IGDistanceCounts
,IGDistanceHistogram
,IGDiameter
,IGFindDiameter
) - Support for weighted clique calculations (
IGWeightedCliques
,IGMaximalWeightedCliques
,IGLargestWeightedCliques
,IGWeightedCliqueNumber
) - Additional new functions
- Syntax highlighting for functions
- Raspberry Pi support
- Compatibility with Mathematica 10.4 on OS X.
- Bug fixes
IGraph/M is licensed under the GNU GPLv2. See LICENSE.txt for details.