{"id":13610782,"url":"https://github.com/igraph/python-igraph","last_synced_at":"2025-05-12T13:18:09.807Z","repository":{"id":25559023,"uuid":"28992184","full_name":"igraph/python-igraph","owner":"igraph","description":"Python interface for igraph","archived":false,"fork":false,"pushed_at":"2025-05-11T09:16:10.000Z","size":34685,"stargazers_count":1367,"open_issues_count":50,"forks_count":256,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-05-12T13:17:36.693Z","etag":null,"topics":["complex-networks","graph-algorithms","graph-theory","mathematics","network-analysis","network-graph","python"],"latest_commit_sha":null,"homepage":"https://python.igraph.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igraph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"igraph","open_collective":"igraph"}},"created_at":"2015-01-08T23:55:16.000Z","updated_at":"2025-05-12T08:48:31.000Z","dependencies_parsed_at":"2024-02-03T23:28:08.372Z","dependency_job_id":"5d12ddec-8dec-4bfd-926b-7b775280f6e1","html_url":"https://github.com/igraph/python-igraph","commit_stats":{"total_commits":2680,"total_committers":80,"mean_commits":33.5,"dds":0.4891791044776119,"last_synced_commit":"bcac78220851628ddb97e43c2bc26efb7660021f"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igraph%2Fpython-igraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igraph%2Fpython-igraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igraph%2Fpython-igraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igraph%2Fpython-igraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igraph","download_url":"https://codeload.github.com/igraph/python-igraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["complex-networks","graph-algorithms","graph-theory","mathematics","network-analysis","network-graph","python"],"created_at":"2024-08-01T19:01:47.959Z","updated_at":"2025-05-12T13:18:09.775Z","avatar_url":"https://github.com/igraph.png","language":"Python","readme":"\n[![Build and test with tox](https://github.com/igraph/python-igraph/actions/workflows/build.yml/badge.svg)](https://github.com/igraph/python-igraph/actions/workflows/build.yml)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/igraph)](https://pypi.python.org/pypi/igraph)\n[![PyPI wheels](https://img.shields.io/pypi/wheel/igraph.svg)](https://pypi.python.org/pypi/igraph)\n[![Documentation Status](https://readthedocs.org/projects/igraph/badge/?version=latest)](https://igraph.readthedocs.io/)\n\n# Python interface for the igraph library\n\nigraph is a library for creating and manipulating graphs.\nIt is intended to be as powerful (ie. fast) as possible to enable the\nanalysis of large graphs.\n\nThis repository contains the source code to the Python interface of\nigraph.\n\nSince version 0.10.2, the documentation is hosted on\n[readthedocs](https://igraph.readthedocs.io). Earlier versions are documented\non [our old website](https://igraph.org/python/versions/0.10.1/).\n\nigraph is a collaborative work of many people from all around the world —\nsee the [list of contributors here](./CONTRIBUTORS.md).\n\n## Citation\n\nIf you use igraph in your research, please cite\n\n\u003e Csardi, G., \u0026 Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, Complex Systems, 1695.\n\n# Installation\n\nWe aim to provide wheels on PyPI for most of the stock Python versions;\ntypically at least the three most recent minor releases from Python 3.x.\nTherefore, running the following command should work without having to compile\nanything during installation:\n\n```\npip install igraph\n```\n\nSee details in [Installing Python Modules](https://docs.python.org/3/installing/).\n\n## Installation from source with pip on Debian / Ubuntu and derivatives\n\nIf you need to compile igraph from source for some reason, you need to\ninstall some dependencies first:\n\n```\nsudo apt install build-essential python-dev libxml2 libxml2-dev zlib1g-dev\n```\n\nand then run\n\n```\npip install igraph\n```\n\nThis should compile the C core of igraph as well as the Python extension\nautomatically.\n\n## Installation from source on Windows\n\nIt is now also possible to compile `igraph` from source under Windows for\nPython 3.7 and later. Make sure that you have Microsoft Visual Studio 2015 or\nlater installed, and of course Python 3.7 or later. First extract the source to\na suitable directory. If you launch the Developer command prompt and navigate to\nthe directory where you extracted the source code, you should be able to build\nand install igraph using `pip install .`, assuming that you have `pip`\ninstalled in your Python environment.\n\nYou may need to set the architecture that you are building on explicitly by setting the environment variable\n\n```\nset IGRAPH_CMAKE_EXTRA_ARGS=-A [arch]\n```\n\nwhere `[arch]` is either `Win32` for 32-bit builds or `x64` for 64-bit builds.\nAlso, when building in MSYS2, you need to set the `SETUPTOOLS_USE_DISTUTILS`\nenvironment variable to `stdlib`; this is because MSYS2 uses a patched version\nof `distutils` that conflicts with `setuptools \u003e= 60.0`.\n\n\u003e [!TIP]\n\u003e You need the following packages:\n\u003e `$MINGW_PACKAGE_PREFIX-python-pip $MINGW_PACKAGE_PREFIX-python-setuptools $MINGW_PACKAGE_PREFIX-cc $MINGW_PACKAGE_PREFIX-cmake`\n\n### Enabling GraphML\n\nBy default, GraphML is disabled, because `libxml2` is not available on Windows in\nthe standard installation. You can install `libxml2` on Windows using\n[`vcpkg`](https://github.com/Microsoft/vcpkg). After installation of `vcpkg` you\ncan install `libxml2` as follows\n\n```\nvcpkg.exe install libxml2:x64-windows-static-md\n```\n\nfor 64-bit version (for 32-bit versions you can use the `x86-windows-static-md`\ntriplet). You need to integrate `vcpkg` in the build environment using\n\n```\nvcpkg.exe integrate install\n```\n\nThis mentions that\n\n\u003e CMake projects should use: `-DCMAKE_TOOLCHAIN_FILE=[vcpkg build script]`\n\nwhich we will do next. In order to build `igraph` correctly, you also\nneed to set some other environment variables before building `igraph`:\n\n```\nset IGRAPH_CMAKE_EXTRA_ARGS=-DVCPKG_TARGET_TRIPLET=x64-windows-static-md -DCMAKE_TOOLCHAIN_FILE=[vcpkg build script]\nset IGRAPH_EXTRA_LIBRARY_PATH=[vcpkg directory]/installed/x64-windows-static-md/lib/\nset IGRAPH_STATIC_EXTENSION=True\nset IGRAPH_EXTRA_LIBRARIES=libxml2,lzma,zlib,iconv,charset\nset IGRAPH_EXTRA_DYNAMIC_LIBRARIES: wsock32,ws2_32\n```\n\nYou can now build and install `igraph` again by simply running `pip install .`.\nPlease make sure to use a clean source tree, if you built previously without\nGraphML, it will not update the build.\n\n## Linking to an existing igraph installation\n\nThe source code of the Python package includes the source code of the matching\nigraph version that the Python interface should compile against. However, if\nyou want to link the Python interface to a custom installation of the C core\nthat has already been compiled and installed on your system, you can ask our\nbuild system to use the pre-compiled version. This option requires that your\ncustom installation of igraph is discoverable with `pkg-config`. First, check\nwhether `pkg-config` can tell you the required compiler and linker flags for\nigraph:\n\n```bash\npkg-config --cflags --libs igraph\n```\n\nIf `pkg-config` responds with a set of compiler and linker flags and not an\nerror message, you are probably okay. You can then proceed with the\ninstallation using pip after setting the environment variable named\n`IGRAPH_USE_PKG_CONFIG` to `1` to indicate that you want to use an\nigraph instance discoverable with `pkg-config`:\n\n```bash\nIGRAPH_USE_PKG_CONFIG=1 pip install igraph\n```\n\nAlternatively, if you have already downloaded and extracted the source code\nof igraph, you can run `pip install` on the source tree directly:\n\n```bash\nIGRAPH_USE_PKG_CONFIG=1 pip install .\n```\n\n(Note that you need the `IGRAPH_USE_PKG_CONFIG=1` environment variable\nfor both invocations, otherwise the call to `pip install` would still\nbuild the vendored C core instead of linking to an existing installation).\n\nThis option is primarily intended for package maintainers in Linux\ndistributions so they can ensure that the packaged Python interface links to\nthe packaged igraph library instead of bringing its own copy.\n\nIt is also useful on macOS if you want to link to the igraph library installed\nfrom Homebrew.\n\nDue to the lack of support of `pkg-config` on MSVC, it is currently not\npossible to build against an external library on MSVC.\n\nIn case you are already using a MSYS2/[MinGW](https://www.mingw-w64.org/) and already have\n[mingw-w64-igraph](https://packages.msys2.org/base/mingw-w64-igraph) installed,\nsimply type:\n```\nIGRAPH_USE_PKG_CONFIG=1 SETUPTOOLS_USE_DISTUTILS=stdlib pip install igraph\n```\nto build.\n\n**Warning:** the Python interface is guaranteed to work only with the same\nversion of the C core that is vendored inside the `vendor/source/igraph`\nfolder. While we try hard not to break API or ABI in the C core of igraph\nbetween minor versions in the 0.x branch and we will keep on doing so for major\nversions once 1.0 is released, there are certain functions in the C API that\nare marked as _experimental_ (see the documentation of the C core for details),\nand we reserve the right to break the APIs of those functions, even if they are\nalready exposed in a higher-level interface. This is because the easiest way to\ntest these functions in real-life research scenarios is to expose them in one\nof the higher level interfaces. Therefore, if you unbundle the vendored source\ncode of igraph and link to an external version instead, we can make no\nguarantees about stability unless you link to the exact same version as the\none we have vendored in this source tree.\n\nIf you are curious about which version of the Python interface is compatible\nwith which version of the C core, you can look up the corresponding tag in\nGithub and check which revision of the C core the repository points to in\nthe `vendor/source/igraph` submodule.\n\n## Compiling the development version\n\nIf you want to install the development version, the easiest way to do so is to\ninstall it using\n\n```bash\npip install git+https://github.com/igraph/python-igraph\n```\n\nThis automatically fetches the development version from the repository, builds\nthe package and installs it. By default, this will install the Python interface\nfrom the `main` branch, which is used as the basis for the development of the\ncurrent release series. Unstable and breaking changes are being made in the\n`develop` branch. You can install this similarly by doing\n\n```bash\npip install git+https://github.com/igraph/python-igraph@develop\n```\n\nIn addition to `git`, the installation of the development version requires some\nadditional dependencies, read further below for details.\n\nFor more information about installing directly from `git` using `pip` see\nhttps://pip.pypa.io/en/stable/topics/vcs-support/#git.\n\nAlternatively, you can clone this repository locally. This repository contains a\nmatching version of the C core of `igraph` as a git submodule. In order to\ninstall the development version from source, you need to instruct git to check\nout the submodules first:\n\n```bash\ngit submodule update --init\n```\n\nCompiling the development version additionally requires `flex` and `bison`. You\ncan install those on Ubuntu using\n\n```bash\nsudo apt install bison flex\n```\n\nOn macOS you can install these from Homebrew or MacPorts. On Windows you can\ninstall `winflexbison3` from Chocolatey.\n\nThen you can install the package directly with `pip` (see also the previous section):\n\n```bash\npip install .\n```\n\nIf you would like to create a source distribution or a Python wheel instead of\ninstalling the module directly in your Python environment, use a standard build\nfrontend like [build](https://pypa-build.readthedocs.io/en/stable/). If you\nuse [pipx](https://pypa.github.io/pipx/) to isolate command-line Python tools\nin their own separate virtualenvs, you can simply run:\n\n```bash\npipx run build\n```\n\n### Running unit tests\n\nUnit tests can be executed from within the repository directory with `tox` or\nwith the built-in `unittest` module:\n\n```bash\npython -m unittest\n```\n\nNote that unit tests have additional dependencies like NumPy, PIL or\n`matplotlib`. The unit test suite will try to do its best to skip tests\nrequiring external dependencies, but if you want to make sure that all the unit\ntests are executed, either use `tox` (which will take care of installing the\ntest dependencies in a virtualenv), or install the module with the `test`\nextras:\n\n```bash\npip install '.[test]'\n```\n\n# Contributing\n\nContributions to `igraph` are welcome!\n\nIf you want to add a feature, fix a bug, or suggest an improvement, open an\nissue on this repository and we'll try to answer. If you have a piece of code\nthat you would like to see included in the main tree, open a PR on this repo.\n\nTo start developing `igraph`, follow the steps above about installing the development version. Make sure that you do so by cloning the repository locally so that you are able to make changes.\n\nFor easier development, you can install `igraph` in \"editable\" (i.e.\ndevelopment) mode so your changes in the Python source code are picked up\nautomatically by Python:\n\n```bash\npip install -e .\n```\n\nChanges that you make to the Python code do not need any extra action. However,\nif you adjust the source code of the C extension, you need to rebuild it by running\n`pip install -e .` again. Compilation of the C core of `igraph` is\ncached in ``vendor/build`` and ``vendor/install`` so subsequent builds are much\nfaster than the first one as the C core does not need to be recompiled.\n\n# Notes\n\n## Supported Python versions\n\nWe aim to keep up with the development cycle of Python and support all official\nPython versions that have not reached their end of life yet. Currently this\nmeans that we support Python 3.9 to 3.13, inclusive. Please refer to [this\npage](https://devguide.python.org/versions/) for the status of Python\nbranches and let us know if you encounter problems with `igraph` on any\nof the non-EOL Python versions.\n\nContinuous integration tests are regularly executed on all non-EOL Python\nbranches.\n\n## PyPy\n\nThis version of igraph is compatible with [PyPy](http://pypy.org/) and\nis regularly tested on [PyPy](http://pypy.org/) with ``tox``. However, the\nPyPy version falls behind the CPython version in terms of performance; for\ninstance, running all the tests takes ~5 seconds on my machine with CPython and\n~15 seconds with PyPy. This can probably be attributed to the need for\nemulating CPython reference counting, and does not seem to be alleviated by the\nJIT.\n\nThere are also some subtle differences between the CPython and PyPy versions:\n\n- Docstrings defined in the C source code are not visible from PyPy.\n\n- ``GraphBase`` is hashable and iterable in PyPy but not in CPython. Since\n  ``GraphBase`` is internal anyway, this is likely to stay this way.\n","funding_links":["https://github.com/sponsors/igraph","https://opencollective.com/igraph"],"categories":["图数据处理","Graph","Graph Manipulation","Python"],"sub_categories":["Others"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figraph%2Fpython-igraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figraph%2Fpython-igraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figraph%2Fpython-igraph/lists"}