Getting Started with grip

Start with a graph whose structure you want to explore. This example uses dwt_307, a 307-vertex structural graph from the SuiteSparse Matrix Collection, supplied with grip. Its edges describe connectivity; the drawing has no known spatial reference that the layout must recover.

Load a graph and draw it

g <- suitesparse.graph('dwt_307')
fit <- metric.mds(edges=g$edges, n=g$n, dim=3, backend="sgd",
                  seed=1, diagnostics=FALSE)
#> Warning: Selected metric.mds() start terminated with iteration_limit; budget
#> exhaustion does not certify convergence; inspect metadata$starts
coords <- fit$coords

Each row of g$edges contains two vertex indices, numbered from 1 to g$n. Each row of coords gives the position of the corresponding vertex. Metric MDS with SGD fits Euclidean separations to graph shortest-path distances. Here all edges have unit length, so targets are hop distances. Inspect the fit diagnostics and termination status; a returned layout does not imply convergence.

dwt_307: 307 vertices. SGD metric MDS with seed 1. Drag to rotate; scroll to zoom.

Rotate the graph to inspect its structure. All vertices and edges are shown. For a quick view in an interactive R session, use:

ivue::plot3D.plain(coords, layers=list(ivue::layer3D.edges(g$edges)), controls = FALSE)

Assess the drawing

quality <- score.layout(coords, edges=g$edges, n=g$n,
                        edge.crossings='never')
knitr::kable(quality[,c('sampled.stress','edge.length.cv',
                       'sampled.nonedge.sep.ratio')],digits=3)
sampled.stress edge.length.cv sampled.nonedge.sep.ratio
0.11 0.225 1.072

Sampled stress compares drawn distances with graph shortest paths after fitting one common scale; smaller values mean closer agreement. Edge-length variation shows how evenly the unit edges are drawn. Nonedge separation describes how far apart unconnected vertices lie relative to edges. These measures describe different aspects of a drawing; no single number captures readability.

Metric MDS controls

metric.mds() directly fits Euclidean distances to graph shortest-path distances. Its default SGD backend adjusts pairs of vertices in shuffled order, following Zheng, Pawar and Goodman (2018) with the learning-rate schedule of Hangan, Kobourov and Miller (2026).

mds <- suppressWarnings(metric.mds(
  edges=g$edges, n=g$n, dim=3, init='random',
  max.iter=80, seed=1, diagnostics=FALSE))
mds$metadata$termination
#> [1] "iteration_limit"

The 80-pass allowance is a short illustrative setting. Schedule completion reports iteration_limit; it does not establish convergence. The figure compares this random-start, 80-pass fit with the default-initialization MDS fit above, which uses the default 1,000-pass budget. The display allows rotation, reflection, and translation and matches overall size with one uniform multiplier per layout. This does not change the fitted coordinates or scores. Because both initialization and budget differ, this is an illustration, not an isolated test of either choice.

dwt_307: two SGD metric-MDS runs with different initialization and pass budgets. Aligned at a common overall size for display. Seed 1. Display multipliers: Random start, 80 passes 1; Default initialization, 1000 passes 1 . Scores use original coordinates.

Select a layout below the figure, or show both. For optimizer and weighting choices, continue to Metric MDS. Larger graphs may benefit from sparse metric MDS.

Choose the next step

Your next question Vignette
What functions are available? Finding your way around grip
What other graphs can I draw? Graph gallery
Which settings or seeds should I use? Choosing and evaluating a layout
How do normalization and distance affect a 3D fit? What does a 3D embedding preserve? (website article)
Should I refit a selection or keep its population coordinates? Local embeddings versus subsets of a global embedding (website article)
How do I compare views with consistent colors, scales and cameras? Comparing scientific views in ivue
My edges represent distances Layouts with meaningful edge lengths
How did the drawing develop? Tracing and diagnosing layouts
How do I explore saved results? Interactive exploration with gripui

Edge values that describe connection strength are not automatically suitable as distances. In particular, the bundled SuiteSparse examples use unit traversal lengths and retain their original matrix values separately. The graph gallery provides source attribution and conversion details.