NetworkX 1.6#
发布日期:2011年11月20日
亮点#
新增函数,用于查找关节点、生成随机二分图、构建邻接矩阵表示、形成图乘积、计算同配系数、测量子图中心性和可达性、查找 k 团社区以及写入 JSON 格式输出。
新增示例,用于使用 D3 JavaScript 库绘图,以及使用 Cuthill-McKee 算法对矩阵进行排序。
电流介数中心性实现了更高效的内存使用,并新增了电流介数中心性和最短路径介数中心性的近似算法。
简化了使用权重/成本/值的算法中对“weight”属性的处理。
更新了所有代码以兼容 PyPy Python 实现 https://pypy.pythonlang.cn,这在许多算法上可提供更快的性能。
图类#
图类(Graph、DiGraph、MultiGraph、MultiDiGraph)中的 degree* 方法现在接受一个可选的 weight= 关键字参数,允许使用任意(数值)边属性计算加权度。将 weight=None 设置等同于之前的 weighted=False。
加权图算法#
许多“加权”图算法现在接受一个可选参数,用于指定哪个边属性应作为权重(默认为’weight’)(问题单 https://networkx.lanl.gov/trac/ticket/573)
在某些情况下,参数名称从 weighted 更改为 weight。以下是如何在算法中指定将使用哪个边属性:
使用 weight=None 表示所有权重相等(无权情况)
使用 weight=’weight’ 表示使用“weight”边属性
使用 weight=’other’ 表示使用“other”边属性
受影响的算法包括
to_scipy_sparse_matrix, clustering, average_clustering, bipartite.degree, spectral_layout, neighbor_degree, is_isomorphic, betweenness_centrality, betweenness_centrality_subset, vitality, load_centrality, mincost, shortest_path, shortest_path_length, average_shortest_path_length
同构#
节点和边属性现在更容易通过“node_match”和“edge_match”参数合并到同构检查中。作为此更改的一部分,以下类已被移除:
WeightedGraphMatcher
WeightedDiGraphMatcher
WeightedMultiGraphMatcher
WeightedMultiDiGraphMatcher
‘is_isomorphic’ 的函数签名现在简化为
is_isomorphic(g1, g2, node_match=None, edge_match=None)
请参阅其 docstring 获取更多详细信息。为了帮助创建“node_match”和“edge_match”函数,鼓励用户使用
categorical_node_match
categorical_edge_match
categorical_multiedge_match
numerical_node_match
numerical_edge_match
numerical_multiedge_match
generic_node_match
generic_edge_match
generic_multiedge_match
这些函数构建可以传递给“is_isomorphic”的函数。最后,请注意,上述函数未导入到顶层命名空间,应从“networkx.algorithms.isomorphism”访问。文档中将重复出现的有用导入语句是:
import networkx.algorithms.isomorphism as iso
其他#
attracting_components
返回一个列表的列表,而不是一个元组的列表。
condensation
凝聚算法现在接受第二个参数 (scc),并返回一个节点标记为整数而不是节点元组的图。
度连通性
average_in_degree_connectivity 和 average_out_degree_connectivity 已被替换为
average_degree_connectivity(G, source=’in’, target=’in’)
以及
average_degree_connectivity(G, source=’out’, target=’out’)
邻居度
average_neighbor_in_degree 和 average_neighbor_out_degreey 已被替换为
average_neighbor_degree(G, source=’in’, target=’in’)
以及
average_neighbor_degree(G, source=’out’, target=’out’)