Installation
Pre-compiled toolboxes
MATLAB's Add-on manager (Recommended)
The toolbox can be installed using MATLAB's Add-on manager. Unless you are interested in developing or learning about the package this is the way to go. The Add-on manager will also handle tracking updates for you. See Get and Manage Add-ons for more information.
After installing you can run igraph.postinstall()
to clean up files that aren't needed on your system. This isn't required but will save space. It will need to be done after each update too.
Downloading from the release page
Alternatively, you can get the toolbox directly from the release page.
There is likely no reason to use this method over the Add-on manager as it will require manually upgrading.
Once the download has been completed, you can double click on the resulting .mltbx
file in the MATLAB IDE and it will guide you through the installation method.
To upgrade download a newer toolbox from the release page and install it through the MATLAB IDE in the same manner as mentioned above.
Compiling from source
For those who want to build the code themselves, this can be done by cloning the git repo and compiling with cmake. If the pre-built toolboxes don't support your architecture, this is the only way to get the toolbox running. It may take a little work to get the build correct for an unsupported architecture. See the igraph C library's installation instructions for obtaining the needed dependencies (note: this toolbox uses igraph's bundled libraries so none you don't need to install any of the optional external libraries). If you do work on getting this toolbox running on a new architecture, you can add an issue or pull-request to the github page to add future support to the toolbox.
Getting the source code
The first thing to do is clone the source code with git. Go to the location you want to store the toolbox and run:
git clone "https://github.com/davidrconnell/matlab-igraph"
git submodule init && git submodule update
Dependencies
Building the toolbox depends on cmake
(and optionally the ninja
build tool) as well as bison
, flex
, and libxml2
.
Building toolbox
From the git command above:
cd matlab-igraph
mkdir build
cd build
cmake ..
cmake --build .
See cmake
's docs for more options.
You may want to build the package target instead of the default target to get a toolbox with all the files in the correct place:
cmake --build . --target package
Then unzip the package and add the contained toolbox to MATLAB's path.
Development
Since the toolbox is a mix of MATLAB source files and compiled files that end up in build directory, the easiest approach for development is to build the default target then link the compiled files to the correct location in the toolbox so MATLAB can find them. From the build directory:
cd ../toolbox/+igraph/private
ln -s ../../../build/mex/*.mexa64 .
cd ../../../tests/mxIgraph/private
ln -s ../../../build/tests/*.mexa64 .
Where mexa64
is the linux mex extension.
If using a different extension, make sure to add a new rule to the .gitignore
file.
Now the source toolbox directory can be added to MATLAB's path and rebuilding the mex files will be recognized by MATLAB (although new files will need to be linked).
There will also be a compile_commands.json
in the build directory that can be linked to the root of the repository.
Testing
Tests can be run using ctest
with the --test-dir
being set to the build directory.
For interactive development, it's faster to run buildtool
in a running MATLAB instance since it doesn't require repeatedly starting MATLAB.
To run all tests:
buildtool test
Test can be replaced with testMxIgraph
or testToolbox
.
Upgrading
Every once in awhile you will want to check for a new release by running git pull
in the matlab-igraph
directory.
If this pulled anything new down, rerun the cmake --build .
command in the build directory.
Making the docs
Hugo is used to create the documentation website.
For viewing the website locally, hugo can be run a local server with hugo server
which should be run in the docs
directory.
When running, hugo will print an address to view the local site.
This site will update as the markdown files under docs/content
at modified.
To make the docs locally, run buildtool makeDocs
, this will export MATLAB livescripts to markdown for the website.