Bandwidth of undirected graphs¶
Definition¶
The bandwidth
Path spanner: alternatively, the bandwidth measures how tightly a path
represents the distance of a graph
Proof: for all
(i.e. ), the constraint ensures that , meaning that adjacent vertices are at distance at most in the path ordering. That alone is sufficient to ensure that . As a byproduct, we obtain that
in general: let be the vertices of a shortest -path. We have:
Satisfiability of a partial assignment¶
Let us suppose that the first
Because of the previous definition,
Applying this rule to all non-assigned vertices, we deduce that each of them
must be assigned to a given interval of
This problem is not always satisfiable, e.g. 5 vertices cannot all be assigned
to the elements of
Solving the matching problem¶
Let
Consider all vertices
sorted increasingly according toFor each of them, assign to
the smallest position in which has not been assigned yet. If there is none, the assignment problem is not satisfiable.
Note that the latest operation can be performed with very few bitset operations
(provided that
The algorithm¶
This section contains totally subjective choices, that may be changed in the hope to get better performances.
Try to find a satisfiable ordering by filling positions, one after the other (and not by trying to find each vertex’ position)
Fill the positions in this order:
Note
There is some symmetry to break as the reverse of a satisfiable ordering is also a satisfiable ordering.
This module contains the following methods¶
Compute the bandwidth of an undirected graph |
|
Use Boost heuristics to approximate the bandwidth of the input graph |
Functions¶
- sage.graphs.graph_decompositions.bandwidth.bandwidth(G, k=None)[source]¶
Compute the bandwidth of an undirected graph.
For a definition of the bandwidth of a graph, see the documentation of the
bandwidth
module.INPUT:
G
– a graphk
– integer (default:None
); set to an integer value to test whether , or toNone
(default) to compute
OUTPUT:
When
is an integer value, the function returns eitherFalse
or an ordering of cost .When
is equal toNone
, the function returns a pair(bw, ordering)
.See also
sage.graphs.generic_graph.GenericGraph.adjacency_matrix()
– return the adjacency matrix from an ordering of the vertices.EXAMPLES:
sage: from sage.graphs.graph_decompositions.bandwidth import bandwidth sage: G = graphs.PetersenGraph() sage: bandwidth(G,3) False sage: bandwidth(G) (5, [0, 4, 5, 8, 1, 9, 3, 7, 6, 2]) sage: G.adjacency_matrix(vertices=[0, 4, 5, 8, 1, 9, 3, 7, 6, 2]) # needs sage.modules [0 1 1 0 1 0 0 0 0 0] [1 0 0 0 0 1 1 0 0 0] [1 0 0 1 0 0 0 1 0 0] [0 0 1 0 0 0 1 0 1 0] [1 0 0 0 0 0 0 0 1 1] [0 1 0 0 0 0 0 1 1 0] [0 1 0 1 0 0 0 0 0 1] [0 0 1 0 0 1 0 0 0 1] [0 0 0 1 1 1 0 0 0 0] [0 0 0 0 1 0 1 1 0 0] sage: G = graphs.ChvatalGraph() sage: bandwidth(G) (6, [0, 5, 9, 4, 10, 1, 6, 11, 3, 8, 7, 2]) sage: G.adjacency_matrix(vertices=[0, 5, 9, 4, 10, 1, 6, 11, 3, 8, 7, 2]) # needs sage.modules [0 0 1 1 0 1 1 0 0 0 0 0] [0 0 0 1 1 1 0 1 0 0 0 0] [1 0 0 0 1 0 0 1 1 0 0 0] [1 1 0 0 0 0 0 0 1 1 0 0] [0 1 1 0 0 0 1 0 0 1 0 0] [1 1 0 0 0 0 0 0 0 0 1 1] [1 0 0 0 1 0 0 1 0 0 0 1] [0 1 1 0 0 0 1 0 0 0 1 0] [0 0 1 1 0 0 0 0 0 0 1 1] [0 0 0 1 1 0 0 0 0 0 1 1] [0 0 0 0 0 1 0 1 1 1 0 0] [0 0 0 0 0 1 1 0 1 1 0 0]
>>> from sage.all import * >>> from sage.graphs.graph_decompositions.bandwidth import bandwidth >>> G = graphs.PetersenGraph() >>> bandwidth(G,Integer(3)) False >>> bandwidth(G) (5, [0, 4, 5, 8, 1, 9, 3, 7, 6, 2]) >>> G.adjacency_matrix(vertices=[Integer(0), Integer(4), Integer(5), Integer(8), Integer(1), Integer(9), Integer(3), Integer(7), Integer(6), Integer(2)]) # needs sage.modules [0 1 1 0 1 0 0 0 0 0] [1 0 0 0 0 1 1 0 0 0] [1 0 0 1 0 0 0 1 0 0] [0 0 1 0 0 0 1 0 1 0] [1 0 0 0 0 0 0 0 1 1] [0 1 0 0 0 0 0 1 1 0] [0 1 0 1 0 0 0 0 0 1] [0 0 1 0 0 1 0 0 0 1] [0 0 0 1 1 1 0 0 0 0] [0 0 0 0 1 0 1 1 0 0] >>> G = graphs.ChvatalGraph() >>> bandwidth(G) (6, [0, 5, 9, 4, 10, 1, 6, 11, 3, 8, 7, 2]) >>> G.adjacency_matrix(vertices=[Integer(0), Integer(5), Integer(9), Integer(4), Integer(10), Integer(1), Integer(6), Integer(11), Integer(3), Integer(8), Integer(7), Integer(2)]) # needs sage.modules [0 0 1 1 0 1 1 0 0 0 0 0] [0 0 0 1 1 1 0 1 0 0 0 0] [1 0 0 0 1 0 0 1 1 0 0 0] [1 1 0 0 0 0 0 0 1 1 0 0] [0 1 1 0 0 0 1 0 0 1 0 0] [1 1 0 0 0 0 0 0 0 0 1 1] [1 0 0 0 1 0 0 1 0 0 0 1] [0 1 1 0 0 0 1 0 0 0 1 0] [0 0 1 1 0 0 0 0 0 0 1 1] [0 0 0 1 1 0 0 0 0 0 1 1] [0 0 0 0 0 1 0 1 1 1 0 0] [0 0 0 0 0 1 1 0 1 1 0 0]