mds_layout

Contents

mds_layout#

graph_tool.draw.mds_layout(g, weight=None, dim=2, pos=None)[git][source]#

Calculate a layout by classical multidimensional scaling of the graph distances.

Parameters:
gGraph

Graph to be used. If it is directed, it is treated as undirected. It must be connected.

weightEdgePropertyMap (optional, default: None)

Non-negative edge lengths. If not supplied, every edge has unit length.

dimint (optional, default: 2)

Number of dimensions of the layout.

posVertexPropertyMap (optional, default: None)

Vector vertex property map where the coordinates are stored.

Returns:
posVertexPropertyMap

Vector vertex property map with the coordinates.

See also

stress_layout

Layout by stress majorization

kamada_kawai_layout

Kamada-Kawai spring layout

spectral_layout

Layout from the eigenvectors of the Laplacian

Notes

Classical multidimensional scaling [torgerson-multidimensional-1952] [gower-some-1966] finds the coordinates whose inner products best approximate those implied by the matrix of squared graph distances \(\boldsymbol D^{(2)}\): the coordinates are the leading dim eigenvectors of \(\boldsymbol B = -\frac{1}{2}\boldsymbol J \boldsymbol D^{(2)}\boldsymbol J\), where \(\boldsymbol J\) is the centering matrix, scaled by the square roots of their eigenvalues. The layout is deterministic, and is often used to initialize kamada_kawai_layout(). It requires the all-pairs distances, in time \(O(V(V+E))\) and \(O(V^2)\) memory, plus the dense eigenvalue problem, in time \(O(V^3)\).

References

[torgerson-multidimensional-1952]

Warren S. Torgerson, “Multidimensional scaling: I. Theory and method”, Psychometrika 17, 401-419 (1952), DOI: 10.1007/BF02288916 [sci-hub, @tor]

[gower-some-1966]

J. C. Gower, “Some distance properties of latent root and vector methods used in multivariate analysis”, Biometrika 53, 325-338 (1966), DOI: 10.1093/biomet/53.3-4.325 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> pos = gt.mds_layout(g)
>>> gt.graph_draw(g, pos=pos, output="karate-mds.pdf")
<...>
../_images/karate-mds.png

Classical multidimensional scaling layout of the karate club network.#