- Notifications
You must be signed in to change notification settings - Fork1
Python interface for igraph
License
iosonofabio/python-igraph
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
igraph is a library for creating and manipulating graphs.It is intended to be as powerful (ie. fast) as possible to enable theanalysis of large graphs.
This repository contains the source code to the Python interface ofigraph.
You can learn more about python-igraphon our website.
We aim to provide wheels on PyPI for most of the stock Python versions;typically the three most recent minor releases from Python 3.x. Therefore,running the following command should work without having to compile anythingduring installation:
$ pip install python-igraphSee details inInstalling Python Modules.
If you need to compile python-igraph from source for some reason, you need toinstall some dependencies first:
$ sudo apt install build-essential python-dev libxml2 libxml2-dev zlib1g-dev bison flexand then run
$ pip install python-igraphThis should compile the C core of igraph as well as the Python extensionautomatically.
The source code of the Python package includes the source code of the matchingigraph version that the Python interface should compile against. However, ifyou want to link the Python interface to a custom installation of the C corethat has already been compiled and installed on your system, you can asksetup.py to use the pre-compiled version. This option requires that yourcustom installation of igraph is discoverable withpkg-config. First, checkwhetherpkg-config can tell you the required compiler and linker flags forigraph:
$ pkg-config --cflags --libs igraphIfpkg-config responds with a set of compiler and linker flags and not anerror message, you are probably okay. You can then proceed with theinstallation using pip:
$ pip install python-igraph --install-option="--use-pkg-config"Alternatively, if you have already downloaded and extracted the source codeof igraph, you can runsetup.py directly:
$ python setup.py build --use-pkg-configThis option is primarily intended for package maintainers in Linuxdistributions so they can ensure that the packaged Python interface links tothe packaged igraph library instead of bringing its own copy.
It is also useful on macOS if you want to link to the igraph library installedfrom Homebrew.
If you have downloaded the source code from Github and not PyPI, chances arethat you have the latest development version, which contains a matching versionof the C core of igraph as a git submodule. Therefore, to install the bleedingedge version, you need to instruct git to check out the submodules first:
git submodule update --initThen, running the setup script should work if you have a C compiler and thenecessary build dependencies (see the previous section):
$ sudo python setup.py buildUnit tests can be executed from the project directory withtox or with thebuilt-in unittest module:
$ python -m unittestContributions topython-igraph are welcome!
If you want to add a feature, fix a bug, or suggest an improvement, open anissue on this repository and we'll try to answer. If you have a piece of codethat you would like to see included in the main tree, open a PR on this repo.
To start developingpython-igraph, follow the steps below (these arefor Linux, Windows users should change the system commands a little).
First, clone this repo (e.g. via https) and enter the folder:
git clone https://github.com/igraph/python-igraph.gitcd python-igraphSecond, check out the necessary git submodules:
git submodule update --init
and install igraph in development mode so your changes in the Python sourcecode are picked up automatically by Python:
python setup.py develop
NOTE: Building requiresCMake, a C compiler, and a few more dependencies.
Changes that you make to the Python code do not need any extra action. However,if you adjust the source code of the C extension, you need to rebuild it by runningpython setup.py develop again. However, compilation of igraph's C core iscached invendor/build andvendor/install so subsequent builds are muchfaster than the first one as the C core does not need to be recompiled.
We aim to keep up with the development cycle of Python and support all officialPython versions that have not reached their end of life yet. Currently thismeans that we support Python 3.6 to 3.9, inclusive. Please refer tothispage for the status of Pythonbranches and let us know if you encounter problems withpython-igraph on anyof the non-EOL Python versions.
Continuous integration tests are regularly executed on all non-EOL Pythonbranches.
Python 2 support has been dropped with the release ofpython-igraph 0.9.
This version of python-igraph is compatible withPyPy andis regularly tested onPyPy withtox. However, thePyPy version falls behind the CPython version in terms of performance; forinstance, running all the tests takes ~5 seconds on my machine with CPython and~15 seconds with PyPy. This can probably be attributed to the need foremulating CPython reference counting, and does not seem to be alleviated by theJIT.
There are also some subtle differences between the CPython and PyPy versions:
Docstrings defined in the C source code are not visible from PyPy.
GraphBaseis hashable and iterable in PyPy but not in CPython. SinceGraphBaseis internal anyway, this is likely to stay this way.
About
Python interface for igraph
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Languages
- Python97.8%
- C1.9%
- Other0.3%