本文簡要介紹
networkx.utils.rcm.cuthill_mckee_ordering
的用法。用法:
cuthill_mckee_ordering(G, heuristic=None)
生成圖節點的排序(排列)以製作稀疏矩陣。
使用Cuthill-McKee啟發式(基於廣度優先搜索)[1]。
- G:圖形
NetworkX 圖
- heuristic:函數,可選
用於選擇 RCM 算法的起始節點的函數。如果 None 使用來自 pseudo-peripheral 對的節點。可以提供一個用戶定義的函數,它接受一個圖形對象並返回一個節點。
- nodes:生成器
Cuthill-McKee 排序中的節點生成器。
參數:
返回:
注意:
帶寬減少的最佳解決方案是NP-complete [2]。
參考:
- 1
E. Cuthill and J. McKee. Reducing the bandwidth of sparse symmetric matrices, In Proc. 24th Nat. Conf. ACM, pages 157-172, 1969. http://doi.acm.org/10.1145/800195.805928
- 2
Steven S. Skiena. 1997. The Algorithm Design Manual. Springer-Verlag New York, Inc., New York, NY, USA.
例子:
>>> from networkx.utils import cuthill_mckee_ordering >>> G = nx.path_graph(4) >>> rcm = list(cuthill_mckee_ordering(G)) >>> A = nx.adjacency_matrix(G, nodelist=rcm)
作為啟發式函數的最小度數節點:
>>> def smallest_degree(G): ... return min(G, key=G.degree) >>> rcm = list(cuthill_mckee_ordering(G, heuristic=smallest_degree))
相關用法
- Python NetworkX cut_size用法及代碼示例
- Python NetworkX connected_double_edge_swap用法及代碼示例
- Python NetworkX categorical_edge_match用法及代碼示例
- Python NetworkX cn_soundarajan_hopcroft用法及代碼示例
- Python NetworkX complete_multipartite_graph用法及代碼示例
- Python NetworkX clustering用法及代碼示例
- Python NetworkX contracted_edge用法及代碼示例
- Python NetworkX circulant_graph用法及代碼示例
- Python NetworkX contracted_nodes用法及代碼示例
- Python NetworkX communicability_exp用法及代碼示例
- Python NetworkX categorical_node_match用法及代碼示例
- Python NetworkX collaboration_weighted_projected_graph用法及代碼示例
- Python NetworkX communicability用法及代碼示例
- Python NetworkX capacity_scaling用法及代碼示例
- Python NetworkX circular_layout用法及代碼示例
- Python NetworkX connected_caveman_graph用法及代碼示例
- Python NetworkX connected_components用法及代碼示例
- Python NetworkX configuration_model用法及代碼示例
- Python NetworkX caveman_graph用法及代碼示例
- Python NetworkX chordal_graph_treewidth用法及代碼示例
- Python NetworkX complete_to_chordal_graph用法及代碼示例
- Python NetworkX communicability_betweenness_centrality用法及代碼示例
- Python NetworkX closeness_vitality用法及代碼示例
- Python NetworkX chordal_graph_cliques用法及代碼示例
- Python NetworkX cytoscape_data用法及代碼示例
注:本文由純淨天空篩選整理自networkx.org大神的英文原創作品 networkx.utils.rcm.cuthill_mckee_ordering。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。