NetworkX

用 Python 进行网络分析。(Network Analysis in Python)

Github stars Tracking Chart

NetworkX

NetworkX 是一个 Python 包,用于创建、操作和研究复杂网络的结构、动态和功能。

简单的例子

找到无向图中两个节点之间的最短路径:

>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_edge('A', 'B', weight=4)
>>> G.add_edge('B', 'D', weight=2)
>>> G.add_edge('A', 'C', weight=3)
>>> G.add_edge('C', 'D', weight=4)
>>> nx.shortest_path(G, 'A', 'D', weight='weight')
['A', 'B', 'D']

安装

安装最新版本的 NetworkX:

  $ pip install networkx

安装所有可选的依赖项:

  $ pip install networkx [all]

有关更多详细信息,请参阅 INSTALL.rst 。

错误

请在 这里 报告你发现的任何错误。或者,甚至更好的是,在 GitHub 上分叉仓库并创建一个拉取请求(PR)。我们欢迎所有的改动,无论大小,如果你是git新手,我们会帮助你创建PR(只需在问题上询问和/或查看CONTRIBUTING.rst)。

许可证

根据 3-clause BSD 许可证发布(请参阅 LICENSE.txt )::

版权所有(C)2004-2018 NetworkX Developers

Copyright (C) 2004-2021 NetworkX Developers
Aric Hagberg <hagberg@lanl.gov>
Dan Schult <dschult@colgate.edu>
Pieter Swart <swart@lanl.gov>


Main metrics

Overview
Name With Ownernetworkx/networkx
Primary LanguagePython
Program languagePython (Language Count: 1)
PlatformLinux, Mac, Windows
License:Other
所有者活动
Created At2010-09-06 00:53:44
Pushed At2025-05-19 04:54:19
Last Commit At
Release Count97
Last Release Namenetworkx-3.5rc0 (Posted on 2025-05-09 08:41:17)
First Release Namenetworkx-0.23 (Posted on )
用户参与
Stargazers Count15.8k
Watchers Count282
Fork Count3.4k
Commits Count8k
Has Issues Enabled
Issues Count3274
Issue Open Count182
Pull Requests Count3143
Pull Requests Open Count190
Pull Requests Close Count808
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

NetworkX

.. image:: https://img.shields.io/pypi/v/networkx.svg
:target: https://pypi.org/project/networkx/

.. image:: https://img.shields.io/pypi/pyversions/networkx.svg
:target: https://pypi.org/project/networkx/

.. image:: https://travis-ci.org/networkx/networkx.svg?branch=master
:target: https://travis-ci.org/networkx/networkx

.. image:: https://ci.appveyor.com/api/projects/status/github/networkx/networkx?branch=master&svg=true
:target: https://ci.appveyor.com/project/dschult/networkx-pqott

.. image:: https://codecov.io/gh/networkx/networkx/branch/master/graph/badge.svg
:target: https://codecov.io/gh/networkx/networkx

NetworkX is a Python package for the creation, manipulation,
and study of the structure, dynamics, and functions
of complex networks.

Simple example

Find the shortest path between two nodes in an undirected graph:

.. code:: python

>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_edge('A', 'B', weight=4)
>>> G.add_edge('B', 'D', weight=2)
>>> G.add_edge('A', 'C', weight=3)
>>> G.add_edge('C', 'D', weight=4)
>>> nx.shortest_path(G, 'A', 'D', weight='weight')
['A', 'B', 'D']

Install

Install the latest version of NetworkX::

$ pip install networkx

Install with all optional dependencies::

$ pip install networkx[all]

For additional details, please see INSTALL.rst.

Bugs

Please report any bugs that you find here <https://github.com/networkx/networkx/issues>.
Or, even better, fork the repository on GitHub <https://github.com/networkx/networkx>

and create a pull request (PR). We welcome all changes, big or small, and we
will help you make the PR if you are new to git (just ask on the issue and/or
see CONTRIBUTING.rst).

License

Released under the 3-Clause BSD license (see LICENSE.txt)::

Copyright (C) 2004-2020 NetworkX Developers
Aric Hagberg hagberg@lanl.gov
Dan Schult dschult@colgate.edu
Pieter Swart swart@lanl.gov