Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python interface for igraph

License

NotificationsYou must be signed in to change notification settings

iosonofabio/python-igraph

 
 

Repository files navigation

Build and test with toxBuild statusPyPI pyversionsPyPI wheels

Python interface for the igraph library

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.

Installation from PyPI

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-igraph

See details inInstalling Python Modules.

Installation from source with pip on Debian / Ubuntu and derivatives

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 flex

and then run

$ pip install python-igraph

This should compile the C core of igraph as well as the Python extensionautomatically.

Linking to an existing igraph installation

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 igraph

Ifpkg-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-config

This 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.

Compiling the development version

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 --init

Then, running the setup script should work if you have a C compiler and thenecessary build dependencies (see the previous section):

$ sudo python setup.py build

Running unit tests

Unit tests can be executed from the project directory withtox or with thebuilt-in unittest module:

$ python -m unittest

Contributing

Contributions 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-igraph

Second, 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.

Notes

Supported Python versions

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.

PyPy

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.

  • GraphBase is hashable and iterable in PyPy but not in CPython. SinceGraphBase is internal anyway, this is likely to stay this way.

About

Python interface for igraph

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python97.8%
  • C1.9%
  • Other0.3%

[8]ページ先頭

©2009-2025 Movatter.jp