當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy csgraph.structural_rank用法及代碼示例

本文簡要介紹 python 語言中 scipy.sparse.csgraph.structural_rank 的用法。

用法:

scipy.sparse.csgraph.structural_rank(graph)#

計算具有給定稀疏模式的圖(矩陣)的結構等級。

矩陣的結構秩是對應二分圖的最大橫向中的條目數,是矩陣數值秩的上界。如果可以排列元素以形成對角線zero-free,則圖具有完整的結構等級。

參數

graph 稀疏矩陣

輸入稀疏矩陣。

返回

rank int

稀疏圖的結構秩。

參考

[1]

I. S. Duff,“計算結構 index ”,SIAM J. Alg。光盤。方法,卷。 7, 594 (1986)。

例子

>>> from scipy.sparse import csr_matrix
>>> from scipy.sparse.csgraph import structural_rank
>>> graph = [
... [0, 1, 2, 0],
... [1, 0, 0, 1],
... [2, 0, 0, 3],
... [0, 1, 3, 0]
... ]
>>> graph = csr_matrix(graph)
>>> print(graph)
  (0, 1)    1
  (0, 2)    2
  (1, 0)    1
  (1, 3)    1
  (2, 0)    2
  (2, 3)    3
  (3, 1)    1
  (3, 2)    3
>>> structural_rank(graph)
4

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.sparse.csgraph.structural_rank。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。