Rank Decompositions of graphs¶
This modules wraps a C code from Philipp Klaus Krause computing a an optimal rank-decomposition [RWKlause].
Definitions :
Given a graph and a subset
of vertices, the rank-width
of
in
, denoted
, is equal to the rank in
of the
matrix of the adjacencies between the vertices of
and
. By definition,
is qual to
where
is the complement of
in
.
A rank-decomposition of is a tree whose
leaves are the elements of
, and whose internal noes have degree 3. In a tree, ay edge naturally
corresponds to a bipartition of the vertex set : indeed, the reoal of any edge
splits the tree into two connected components, thus splitting the set of leaves
(i.e. vertices of
) into two sets. Hence we can define for any edge
a width equal to the value
or
, where
is the bipartition obtained from
. The rank-width
associated to the whole decomposition is then set to the maximum of the width of
all the edges it contains.
A rank-decomposition is said to be optimal for if it is the decomposition
achieving the minimal rank-width.
RW – The original source code :
RW [RWKlause] is a program that calculates rank-width and rank-decompositions. It is based on ideas from :
OUTPUT:
The rank decomposition is returned as a tree whose vertices are subsets of
. Its leaves, corresponding to the vertices of
are sets of 1 elements,
i.e. singletons.
sage: g = graphs.PetersenGraph()
sage: rw, tree = g.rank_decomposition()
sage: all(len(v)==1 for v in tree if tree.degree(v) == 1)
True
The internal nodes are sets of the decomposition. This way, it is easy to deduce the bipartition associated to an edge from the tree. Indeed, two adjacent vertices of the tree are comarable sets : they yield the bipartition obtained from the smaller of the two and its complement.
sage: g = graphs.PetersenGraph()
sage: rw, tree = g.rank_decomposition()
sage: u = Set([8, 9, 3, 7])
sage: v = Set([8, 9])
sage: tree.has_edge(u,v)
True
sage: m = min(u,v)
sage: bipartition = (m, Set(g.vertices()) - m)
sage: bipartition
({8, 9}, {0, 1, 2, 3, 4, 5, 6, 7})
Warning
- The current implementation cannot handle graphs of
vertices.
- A bug that has been reported upstream make the code crash immediately on
instances of size
. If you experience this kind of bug please report it to us, what we need is some information on the hardware you run to know where it comes from !
EXAMPLE:
sage: g = graphs.PetersenGraph()
sage: g.rank_decomposition()
(3, Graph on 19 vertices)
AUTHORS:
- Philipp Klaus Krause : Implementation of the C algorithm [RWKlause].
- Nathann Cohen : Interface with Sage and documentation.
REFERENCES:
[RWKlause] (1, 2, 3) Philipp Klaus Krause – rw v0.2 http://pholia.tdi.informatik.uni-frankfurt.de/~philipp/software/rw.shtml
[Oum] Sang-il Oum Computing rank-width exactly Information Processing Letters, 2008 vol. 109, n. 13, p. 745–748 Elsevier http://mathsci.kaist.ac.kr/~sangil/pdf/2008exp.pdf
[BL] Buckles, B.P. and Lybanon, M. Algorithm 515: generation of a vector from the lexicographical index ACM Transactions on Mathematical Software (TOMS), 1977 vol. 3, n. 2, pages 180–182 ACM
[AW] Adams, M.D. and Wise, D.S. Fast additions on masked integers ACM SIGPLAN Notices, 2006 vol. 41, n.5, pages 39–45 ACM http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.86.1801&rep=rep1&type=pdf
Methods¶
-
sage.graphs.graph_decompositions.rankwidth.
mkgraph
(num_vertices)¶ Return the graph corresponding to the current rank-decomposition.
(This function is for internal use)
EXAMPLE:
sage: from sage.graphs.graph_decompositions.rankwidth import rank_decomposition sage: g = graphs.PetersenGraph() sage: rank_decomposition(g) (3, Graph on 19 vertices)
-
sage.graphs.graph_decompositions.rankwidth.
rank_decomposition
(G, verbose=False)¶ Computes an optimal rank-decomposition of the given graph.
This function is available as a method of the
Graph
class. Seerank_decomposition
.INPUT:
verbose
(boolean) – whether to display progress information while computing the decomposition.
OUTPUT:
A pair
(rankwidth, decomposition_tree)
, whererankwidth
is a numerical value anddecomposition_tree
is a ternary tree describing the decomposition (cf. the module’s documentation).EXAMPLE:
sage: from sage.graphs.graph_decompositions.rankwidth import rank_decomposition sage: g = graphs.PetersenGraph() sage: rank_decomposition(g) (3, Graph on 19 vertices)
On more than 32 vertices:
sage: g = graphs.RandomGNP(40, .5) sage: rank_decomposition(g) Traceback (most recent call last): ... RuntimeError: the rank decomposition cannot be computed on graphs of >= 32 vertices
The empty graph:
sage: g = Graph() sage: rank_decomposition(g) (0, Graph on 0 vertices)