网络X 2.7#

上映日期:2022年2月28日

支持Python3.8、3.9和3.10

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

欲了解更多信息,请访问我们的 website 还有我们的 gallery of examples 。请将意见和问题发送到 networkx-discuss mailing list

集锦#

这个版本是经过7个月的工作,33个贡献者超过166个拉请求的结果。亮点包括:

警告

的输出中观察到的哈希值 weisfeiler_lehman_graph_hash 由于错误修复,已在版本2.7中进行了更改。看见 gh-4946 了解更多细节。这意味着,比较用不同版本的NetworkX(即版本2.7之前和之后)计算的同一图的散列可能会错误地未能通过同构测试(同构的图总是具有匹配的Weisfeler-Lehman散列)。建议用户重新计算他们在升级时可能拥有的任何存储的图哈希。

  • 放弃了对Python3.7的支持。

  • 增加了求解非对称旅行商问题的Asadour算法: asadpour_atsp

  • 新增了Louvain社区检测算法: louvain_communitieslouvain_partitions

  • 已删除所有内部使用 numpy.matrix 类,并添加了一个 FutureWarning 对所有返回 numpy.matrix 举个例子。这个 numpy.matrix 类将被2D替换 numpy.ndarray NetworkX 3.0中的实例。

  • 添加了对 scipy.sparse 阵列接口。这包括 to_scipy_sparse_arrayfrom_scipy_sparse_array 。在NetworkX 3.0中,稀疏数组将取代稀疏矩阵作为 scipy.sparse 。新代码应使用 to_scipy_sparse_arrayfrom_scipy_sparse_array 而不是它们的矩阵对应物。此外,许多当前返回稀疏矩阵的函数现在都会引发 FutureWarning 以指示它们将在NetworkX 3.0中改为返回稀疏数组。

  • 添加了对泛型数据类型的支持 to_numpy_array 。这增加了对通用属性的支持,例如具有复数权重的邻接矩阵。这还增加了对处理多图权重时的一般约简函数的支持,例如 meanmedian 。最后,这还包括对结构化数据类型的支持,它允许创建多属性邻接矩阵,并取代不太通用的 to_numpy_recarray

  • 添加了对计算多重图的介数中心性的支持

  • 添加了对有向图和多重图的支持 greedy_modularity_communities

GSOC PR#

我们添加了四个Google Summer of Code项目中的工作:

改进#

  • [#4740] Add the Asadpour algorithm for solving the asymmetric traveling salesman problem.

  • [#4897] Improve the validation and performance of nx.is_matching, nx.is_maximal_matching and nx.is_perfect_matcing.

  • [#4924] Fix handling of disconnected graphs whne computing nx.common_neighbor_centrality.

  • [#4929] Add Louvain community detection.

  • [#4946] Add Weisfeiler-Lehman hashing subgraph hashing.

  • [#4950] Add an n_communities parameter to greedy_modularity_communities to terminate the search when the desired number of communities is found.

  • [#4965] and [#4996] Fix handling of relabeled nodes in greedy_modularity_communities.

  • [#4976] Add betweenness centrality for multigraphs.

  • [#4999] Fix degree_assortativity_coefficient for directed graphs.

  • [#5007] Add support for directed graphs and multigraphs to greedy_modularity_communities.

  • [#5017] Improve implementation and documentation of descendants and ancestors

  • [#5019] Improve documentation and testing for directed acyclic graph module.

  • [#5029] Improve documentation and testing of descendants_at_distance.

  • [#5032] Improve performance of complement_edges.

  • [#5045] Add geometric_edges to the nx namespace.

  • [#5051] Add support for comment characters for reading data with read_edgelist.

  • [#5052] Improve performance and add support for undirected graphs and multigraphs to transitive_closure.

  • [#5058] Improve exception handling for writing data in GraphML format.

  • [#5065] Improve support for floating point weights and resolution values in greedy_modularity_communities.

  • [#5077] Fix edge probability in fast_gnp_random_graph for directed graphs.

  • [#5086] Fix defect in lowest_common_ancestors.

  • [#5089] Add find_negative_cycle for finding negative cycles in weighted graphs.

  • [#5099] Improve documentation and testing of binary operators.

  • [#5104] Add support for self-loop edges and improve performance of vertex_cover.

  • [#5121] Improve performance of *_all binary operators.

  • [#5131] Allow edge_style to be a list of styles when drawing edges for DiGraphs.

  • [#5139] Add support for the scipy.sparse array interface.

  • [#5144] Improve readibility of node_classification functions.

  • [#5145] Adopt math.hypot which was added in Python 3.8.

  • [#5153] Fix multipartite_layout for graphs with non-numeric nodes.

  • [#5154] Allow arrowsize to be a list of arrow sizes for drawing edges.

  • [#5172] Add a nodes keyword argument to find_cliques to add support for finding maximal cliques containing only a set of nodes.

  • [#5197] Improve resistance_distance with advanced indexing.

  • [#5216] Make omega() closer to the published algorithm. The value changes slightly. The niter parameter default changes from 1->5 in lattice_reference() and from 100->5 in omega.

  • [#5217] Improve performance and readability of betweenness_centrality.

  • [#5232] Add support for None edge weights to bidirectional Djikstra algorithm.

  • [#5247] Improve performance of asynchronous label propagation algorithm for community detection, asyn_lpa_communities.

  • [#5250] Add generic dtype support to to_numpy_array.

  • [#5285] Improve karate_club_graph by updating to the weighted version from the original publication.

  • [#5287] Improve input validation for json_graph.

  • [#5288] Improve performance of strongly_connected_components.

  • [#5324] Add support for structured dtypes to to_numpy_array.

  • [#5336] Add support for the numpy.random.Generator interface for random number generation.

API更改#

  • 返回的字典中的值 rescale_layout_dict 现在是 numpy.ndarray 对象而不是元组。这使得返回类型为 rescale_layout_dict 与所有其他布局功能一致。

  • A FutureWarning 已添加到 google_matrix 以指示返回类型将从 numpy.matrix 对象添加到 numpy.ndarray 在NetworkX 3.0中。

  • A FutureWarning 已添加到 attr_matrix 以指示返回类型将从 numpy.matrix 对象添加到 numpy.ndarray NetworkX 3.0中的对象。

  • 这个 is_*_matching 函数现在为任何边中不在G中的节点引发异常。

贬抑#

  • [#5055] Deprecate the random_state alias in favor of np_random_state

  • [#5114] Deprecate the name kwarg from union as it isn't used.

  • [#5143] Deprecate euclidean in favor of math.dist.

  • [#5166] Deprecate the hmn and lgc modules in node_classification.

  • [#5262] Deprecate to_scipy_sparse_matrix and from_scipy_sparse_matrix in favor of to_scipy_sparse_array and from_scipy_sparse_array, respectively.

  • [#5283] Deprecate make_small_graph and make_small_undirected_graph from the networkx.generators.small module.

  • [#5330] Deprecate to_numpy_recarray in favor of to_numpy_array with a structured dtype.

  • [#5341] Deprecate redundant info.

合并的请购单#

共有166项变更已提交。

  • 支持 comments=None 在读取/分析边列表中(#5051)

  • 将另请参阅引用添加到GML文档字符串中的反/字符串化程序。(#5053)

  • 添加威斯费勒雷曼子图散列(#4946)

  • 不推荐使用 random_state 装饰师(#5055)

  • 问题#5023的错误修复:Single_SOURCE_Dijkstra中的角例错误(#5033)

  • 信息量更大的GraphML异常(#5058)

  • 对tutorial.rst进行了较小的更新,并为节点/边的数据方法添加了文档字符串(#5039)

  • 文档 geometric_edges 并将其添加到主命名空间(#5045)

  • 修正小的打字错误 trophic_levels 文档(#5087)

  • 重构 transitive_closure (#5052)

  • 修复有向图的FAST_GNP_RANDOM_GRAPH(问题#3389)(#5077)

  • 通过调用适当的方法获取边数(#5095)

  • 更新文档中的指导项目部分(#5056)

  • 对最短路径节点检查测试进行参数化。(#5078)

  • 创建FundING.yml

  • 不推荐使用联合名称参数(#5114)

  • 更新FundING.yml

  • VERTEX_COVER:增加了对自循环节点的支持(#5104)

  • 更新核心开发团队(#5119)

  • 算法/运算符/all.py中的运算符速度更快(#5121)

  • DOC:添加已完成项目建议书的链接(#5122)

  • RESALE_LAYOUT和RESALE_LAYOUT_DICT的字典输出中的返回类型一致(#5091)

  • 将异常变量名e更改为错误(#5130)

  • 分类文档和代码中的微小调整(#5129)

  • 允许边缘样式成为有向图的样式列表(#5131)

  • 为运算符/binary.py添加示例和次要文档重构(#5099)

  • 改进GNP生成器的随机图测试套件(问题#5092)(#5115)

  • 向ALL_SIMPLE_PATHS添加有关检查路径存在的说明。(#5059)

  • 修复了装饰器中引发异常的消息。(#5136)

  • 重构FancyArrowPatches的线型测试。(#5132)

  • 丢弃PY37(#5143)

  • 使用数学假设(#5145)

  • 将pyUpgrade添加到预提交(#5146)

  • 在Python3.10(#4807)上进行测试

  • 使用黑色21.9b0(#5148)

  • 使用狮身人面像4.2(#5150)

  • 更新示例要求(#5151)

  • 更新NX_PYLAB绘图边缘颜色和宽度测试(#5134)

  • 重构NODE_分类以提高简洁性和可读性(#5144)

  • 添加临时PYPARING PIN以修复CI。(#5156)

  • 将ArrowSize选项添加为列表(#5154)

  • 列出策略(#5159)

  • 修复了问题5123(#5153)

  • 在PY3.10上测试鲸鱼和熊猫(#5174)

  • 不推荐使用 hmnlgc 中的模块 node_classification 套餐(#5166)

  • Rm将ax.TransOffset传递到LineCollection。(#5173)

  • 添加一个函数以使用BELMAN_FORT(#5089)找到负循环

  • 在贡献者常见问题解答中添加一个关于算法接受策略的问答。(#5177)

  • 文档:修复文档中加权最短路径的拼写错误(#5181)

  • 还原“Add Temporary pyparsing Pin to Fix CI.(#5156)”(#5180)

  • 使用时仅计算最短路径长度(#5183)

  • 添加Mypy类型检查基础结构(#5127)

  • X失败的PYDot测试。(#5187)

  • 从代数连接中删除未使用的内部求解器(#5190)

  • 删除对Scipy 1.1行为的检查/注释。(#5191)

  • 在Python3.10(#5185)上进行测试

  • 使用undir为祖先/后代添加回归测试。G.(#5188)

  • Rm内部函数,改用高级索引。(#5197)

  • 修复拉普拉斯FNS中缺少的导入+测试。(#5194)

  • 调查发布前测试失败(#5208)

  • 支持断言语句的RM断言方法。(#5214)

  • 删除mycielski.py中未使用的变量(#5210)

  • 使用队列而不是普通列表(#5217)

  • 将关于矩阵的FutureWarning->数组输出添加到 google_matrix (#5219)

  • 几个 np.matrix 清理(#5218)

  • 支持拉普拉斯矩阵的内部拉普拉斯矩阵。(#5196)

  • [MRG] Create plot_subgraphs.py example (#5165)

  • 将旅行推销员问题添加到示例库(#4874)

  • 修复了DiGraph.edge()中nBunch参数的文档不一致问题(#5037)

  • 来自与NumPy/Scipy/Pest RC的测试的兼容性更新(#5226)

  • 更换内部 close FN(带) math.isclose 。(#5224)

  • 使用int div修复了Python3.10不推荐使用警告。(#5231)

  • 子图图库示例的改进和建议(#5225)

  • 使用新程序包名称(#5234)

  • 双向Dijkstra的权函数不允许有边(#5232)

  • 添加有关分配问题的常见问题解答。(#5182)

  • 更新开发人员(#5243)

  • 使用TeX表示法更新次要文档问题(#5244)

  • 较小的更改可加快社区检测的异步标签传播速度。(#5247)

  • 用于Small.py模块的文档字符串(#5240)

  • 使用scipy.parse数组数据结构(#5139)

  • 更新狮身人面像(#5272)

  • 更新年份(#5273)

  • 更新额外的依赖项(#5263)

  • 更新文档中的gexf网站链接(#5275)

  • 更新数字文档(#5274)

  • LAZY_IMPORT函数的初始设置。(#4909)

  • 不推荐使用Scipy稀疏矩阵转换函数(#5262)

  • 修复LOST_COMMON_ANASHORS(问题#4942)(#5086)

  • 使小图形生成器节点测试更加具体。(#5282)

  • 在生成器中使用from_dict_of_list而不是make_mall_graph。Small(#5267)

  • 重构 to_numpy_array 使用高级索引(#5250)

  • FIX:更新阈值的Louvain_Partitions(将每个级别的mod更新为new_mod)(#5284)

  • 为未连接的图表添加例外(#5287)

  • 修正Tarjan的强连通分量算法实现,使其具有O( |E| + |V| )时间复杂度而不是O( |V| ^3)。(#5288)

  • 为空手道俱乐部图添加权重(#5285)

  • 修复出现在变量中的函数 __all__ 但不在NX2.7的文档中(#5289)

  • 更新到稳定版本的Black(#5296)

  • 将未来警告添加到 attr_matrix 通知用户返回类型更改(#5300)

  • DOC:将NXEP2的状态更改为已接受,添加解决方案(#5297)

  • 更新测试要求(#5304)

  • 更新Scipy(#5276)

  • DOC:更新文档以包括重量论证的可计算内容(#5307)

  • 更新pygraph viz(#5314)

  • 将默认数据类型记录在to_numpy_recarray文档字符串中。(#5315)

  • RM未使用的抽象集。(#5317)

  • 不推荐使用 make_small_graphmake_small_undirected_graph (#5283)

  • 更新 draw_ 带有用法示例的文档字符串(#5264)

  • NX2.7的更多数字矩阵清理(#5319)

  • 维护:清理分类模块,删除不使用的变量(#5301)

  • 添加用于绘制多边标签的信息性例外。(#5316)

  • 文档中函数的完整路径的潜在解决方案(#5049)

  • 维护:清理链接分析模块,删除未使用的变量(#5306)

  • 使用pytest-mpl(#4579)

  • 把欧米茄放在心里 [-1, 1] 界限(#5216)

  • 添加对查找包含一组节点的最大团的支持(#5172)

  • 维护:删除不必要的助手函数,使用折线图生成器的内置方法(#5327)

  • 已弃用从dict_key对象进行采样。(#5337)

  • 添加对以下各项的支持 numpy.random.Generator (#5336)

  • 更新匹配函数以进行错误验证和速度(#4897)

  • 更新版本要求(#5338)

  • 将结构化数据类型添加到 to_numpy_array (#5324)

  • 不推荐使用 to_numpy_recarray (#5330)

  • 第一次通过2.7版本说明。(#5342)

  • 添加泡菜和YAML迁移信息(#5345)

  • 不推荐使用信息(#5341)

  • 修复熊猫警告(#5346)

  • 3.11-dev上的测试(#5339)

  • 指定2.7rc1版本

  • 凹凸释放版本

  • 更新发布过程(#5348)

  • 使用预期时间承诺更新指导项目信息(#5349)

  • 在示例+其他更新中使用np.随机性.defaultrng。(#5356)

  • 删除Conda不支持的内容(#5361)

  • 当等距为True时修复螺旋布局(#5354)

  • 修复文档(#5364)

贡献者#

  • 威尔·巴达特

  • 罗斯巴诺夫斯基

  • 马修·巴斯蒂安

  • 马丁·贝克尔

  • 阿努托什·巴特

  • 亚历杭德罗·卡迪奥蒂

  • 迪维扬什

  • 安德鲁·埃卡特

  • 尤西·埃利亚兹

  • 卡斯珀·范·埃特伦

  • 西蒙·加斯佩里尼

  • 丹尼尔·哈登

  • 利奥·克拉纳

  • 安德鲁·克尼亚泽夫

  • 法布里齐奥·库鲁奇

  • 帕尔思·马丹

  • 贾罗尔米尔曼

  • 阿奇勒·拿撒勒

  • NikHoh

  • 苏丹·奥拉兹巴耶夫

  • 迪米特里奥斯·帕佩佐吉奥

  • Aishwarya Ramasethu

  • 琉球

  • 卡塔林·施密特

  • 丹舒尔特

  • 塞思

  • Cirus Thenter

  • 詹姆斯·特林布尔

  • 瓦迪姆

  • 哈纳蒂乌克·弗拉迪斯拉夫

  • Aaron Z

  • 埃斯库蒂斯

  • 黑莓