passagemath-rankwidth

raw JSON →
10.8.4 verified Fri May 01 auth: no python

passagemath-rankwidth provides functions for computing rankwidth and rank decompositions of graphs using the rw library. Part of the passagemath ecosystem. Current version: 10.8.4, released as part of passagemath 10.8. Release cadence follows passagemath releases (roughly 2-3 per year).

pip install passagemath-rankwidth
error ModuleNotFoundError: No module named 'passagemath.graphs.rankwidth'
cause The package passagemath-rankwidth is not installed or not properly imported.
fix
Run 'pip install passagemath-rankwidth' and ensure you use the correct import path: from passagemath.graphs.rankwidth import rankwidth
error ValueError: algorithm must be one of 'rw', 'cunningham', 'exact'
cause You passed an invalid algorithm string.
fix
Use 'rw' or 'cunningham' (the latter replaces the deprecated 'exact').
error RuntimeError: rw executable not found
cause The external 'rw' library is not installed on the system.
fix
Install rw (e.g., sudo apt install rw) or use algorithm='cunningham'.
breaking The import path has changed from sage.graphs.rankwidth to passagemath.graphs.rankwidth. Old imports will fail.
fix Use 'from passagemath.graphs.rankwidth import rankwidth' instead.
gotcha The rw algorithm (the default) uses the external 'rw' library, which must be installed as a system dependency. pip install does not install it automatically.
fix Install the rw library (e.g., on Debian/Ubuntu: apt-get install rw) or set algorithm='cunningham' for a pure Python implementation.
deprecated The 'algorithm' parameter 'exact' is deprecated in favor of 'cunningham' for the exact decomposition method.
fix Use algorithm='cunningham' instead of algorithm='exact'.
gotcha The function returns a tuple (rankwidth, decomposition). The decomposition is a linear ordering representation, not a tree. Do not expect a tree structure.
fix Access the rankwidth as the first element, and the decomposition as the second.

Compute the rankwidth of the Petersen graph using the rw algorithm.

from passagemath.graphs.rankwidth import rankwidth
g = graphs.PetersenGraph()
rw, decomp = rankwidth(g, algorithm='rw')
print(rw)