Opened 7 years ago

Last modified 7 years ago

#18929 closed enhancement

Include igraph library — at Version 10

Reported by: borassi Owned by:
Priority: major Milestone: sage-6.9
Component: packages: optional Keywords: igraph library
Cc: ncohen, dcoudert, vbraun Merged in:
Authors: Michele Borassi Reviewers:
Report Upstream: N/A Work issues:
Branch: u/borassi/include_igraph_library (Commits, GitHub, GitLab) Commit: 1ca4c05f87ac4bc0637982b53521e723f96f2071
Dependencies: Stopgaps:

Status badges

Description (last modified by borassi)

Include igraph library ![1] in Sagemath, so that we can use its algorithms. Add routines to convert Sage graphs into igraph and viceversa. The input files are available through the following links:

  • for igraph.tar.gz:
  • for python-igraph.tar.gz:

The modified files (with script spkg_src) are available through the following links:

  • for igraph.tar.gz (the same as the previous one):
  • for python-igraph.tar.gz (we had to replace - with _ in the filename and in a folder):

If we manage to include igraph, we will have access to 62 algorithms on graphs: 29 of them are not available in Sage, yet ![2].



Change History (10)

comment:1 Changed 7 years ago by borassi

  • Authors set to Michele Borassi
  • Cc ncohen dcoudert vbraun added
  • Component changed from PLEASE CHANGE to packages: optional
  • Description modified (diff)
  • Keywords igraph library added
  • Status changed from new to needs_info
  • Type changed from PLEASE CHANGE to enhancement


With this ticket, I would like to add igraph library to Sage. I have tried to follow as much as possible the instructions in ![1], to include the following external libraries:

  • igraph-0.7.1, available in ![2] (the C/C++ core of igraph);
  • python-igraph-0.7.0, available in ![3] (the Python interface).

In order to build this code, you should do the following.

  • Download the two .tar.gz source code files [2,3] and put them in folder SAGE_ROOT/upstream (this folder is not synchronized with git).
  • run the script SAGE_ROOT/build/pkgs/python_igraph/spkg-src from folder SAGE_ROOT, with command ./build/pkgs/python_igraph/spkg-src. The problem is that Sage does not like dashes inside the package name: the script converts the file python-igraph-0.7.0.tar.gz into python_igraph-0.7.0.gz (it is also necessary to modify the name of a folder inside the tar archive).

I am not really sure about the procedure (in particular, about spkg-src), so I would like to have feedback, also related to ticket #18826.

Thank you very much!




comment:2 Changed 7 years ago by borassi

  • Branch set to u/borassi/include_igraph_library

comment:3 Changed 7 years ago by git

  • Commit set to 388abfbfec5b9d8255ff83efbdfc4a61a076ffce

Branch pushed to git repo; I updated commit sha1. New commits:

388abfbModified spkg-src according to Nathann's suggestions.

comment:4 Changed 7 years ago by borassi

  • Status changed from needs_info to needs_review


I have modified spkg-src, taking inspiration from the spkg-src file of bzip2 in ticket #18826. I have added the dependencies, but I'm not really sure if I have done it correctly (I have no idea of where variable $(IGRAPH) is defined).

Thank you very much!


comment:5 Changed 7 years ago by ncohen

  • Status changed from needs_review to needs_work

Helloooooooo Michele,

I have not installed the two igraph packages yet (the reason will follow) but it seems that you did well with the 'dependencies' file. The 'IGRAPH' variable is a bit magic it's true: it is generated from the package's name, and you should find it in SAGE_ROOT/build/make/Makefile somewhere. If you look for PYTHON_IGRAPH you should see the dependency that you added in this 'dependencies' file.

I added a small commit at public/18929 that does not do anything smart. I flagged the new doctests with # optional - python_igraph so that they are only run if the python_igraph is installed (they would break otherwise), though there remains some problem to deal with: you cannot import 'igraph' in the (Di)Graph constructor, for this package is optional. I ran the tests before installing the package, and well.. Everything break. Even this:

sage: Graph()
ImportError: No module named igraph

Sooo perhaps you should 'detect' the presence of this module with something like that (unless you find something better):

    import igraph
    _python_igraph_available = True
except ImportError:
    _python_igraph_available = False    

In the same way, your 'import igraph' in GenericGraph.igraph_graph would generate, when called on a machine on which the package is not installed, an ImportError. We usually try to give something easier to work with, like an error message advising to install a package named <package_name> to enable this feature.

Have fuuuuuuun,


comment:6 Changed 7 years ago by git

  • Commit changed from 388abfbfec5b9d8255ff83efbdfc4a61a076ffce to 1ca4c05f87ac4bc0637982b53521e723f96f2071

Branch pushed to git repo; I updated commit sha1. New commits:

efac72fMerge branch 'develop' into t/18929/include_igraph_library
cc5c10etrac #18929: Merged with 6.8
8c49588trac #18929: Reviewer's commit
a82f7f2Merged with Nathann's work
1ca4c05Solved bug if igraph is not installed

comment:7 Changed 7 years ago by borassi


Ups, you were right: if igraph is not installed, nothing works anymore. I have corrected it, and I have included your commit (we both merged with 6.8...).

Now everything should work (I have performed a test of all the graph part, and all tests were passed).

See you, Michele

comment:8 Changed 7 years ago by ncohen

Hello again Michele,

I was about to try to install the two packages and so I downloaded igraph's sources, but it seems that there is something wrong with the checksums:

(tmp|✔)~/.Sage$ sage -i igraph
Found local metadata for igraph-0.7.1
Invalid checksum for cached file /home/ncohen/.Sage/upstream/igraph-0.7.1.tar.gz, deleting

Could you also provide direct links toward the archive files in the ticket's description? This is for the release manager who will have to add them to Sage's repository.

In the second case, i.e. the python_igraph file (as it is not vanilla upstream), it means uploading it on some server of yours so that it can be downloaded from there. The purpose of ticket #18826 is precisely to give us an easy way to 'check', in such situations, that the archive uploaded by one of us is exactly what it should.


comment:9 Changed 7 years ago by ncohen

Oh, and something else I forgot: it is not sufficient to add the edges in order to get the graph: isolated vertices would not appear in this case.


comment:10 Changed 7 years ago by borassi

  • Description modified (diff)
  • Status changed from needs_work to needs_review


I have done it: sorry, but I'm not very experienced with new packages, so I need lots of advices and comments, even to solve stupid issues...


Note: See TracTickets for help on using tickets.