# How to zoom, pan and otherwise visualize a huge graph?

I have a complicated tree I'd like to zoom in and investigate. It's quite dense and large.

Here's a simple way to reproduce the problem (my graph has 30K elements) but the 1K elements of this graph do a reasonable job as well.

g = Module[{weights, n = 1000},
weights = Table[RandomReal[{0, Abs[i - j]^0.25 // N}], {i, n}, {j, n}];
FindSpanningTree[
weights + Transpose[weights]]]
]


When I run the above, I get a graph that looks like:

I'm interested in being able to zoom in/out easily (mouse wheel zooms in/out centered on the position of the mouse for instance).

Bonus points, if the zooming handles labels well. By default:

Graph[g, VertexLabels->"Name", EdgeLabels->"EdgeWeight"]


looks pretty atrocious.

• You can try the 3D zoom/pan/rotate tools with GraphPlot3D[g]. Not sure it qualifies as being done "easily," though. Commented Mar 20, 2023 at 0:31
• DynamicImage[Show@g]?
– kglr
Commented Mar 20, 2023 at 0:32
• Maybe this, if the rasterization of DynamicImage isn't acceptable: gp = GraphPlot[g, VertexLabels -> "Name", EdgeLabels -> "EdgeWeight"]; viewRange = {{0.68, 0.72}, {0.63, 0.67}}; Show[gp, PlotRangePadding -> None, PlotRange -> MapThread[Rescale, {viewRange, {{0., 1.}, {0., 1.}}, PlotRange@gp}]]. You'd have to add the mouse interaction. DynamicImage is easier, though. Commented Mar 20, 2023 at 0:47
• @MichaelE2, GraphPlot3D is it. Zooming can be done (on Windoze) with <CTRL> panning with <SHIFT> and mousing. Make that an answer and I'll accept it.
– John
Commented Mar 20, 2023 at 1:46
• @MichaelE2 I suppose the next obvious question (to me) is, "why isn't this just part of 2D rendering? Or, is 3D rendering just how you're supposed to interact with graphics in general? DynamicImage sucks for this application.
– John
Commented Mar 20, 2023 at 1:47