v.net.allpairs(1grass)

πŸ’– v.net.allpairs β€” the GRASS manual, but make it a group chat πŸ’–

okay bestie, so you know how sometimes you need to know every single shortest path between every single pair of nodes in your network? yeah. that's this. it's v.net.allpairs, a GRASS GIS module, and it's lowkey iconic for it.

KEYWORDS: vector, network, shortest path πŸ¦‹


✨ SYNOPSIS ✨

v.net.allpairs
v.net.allpairs --help
v.net.allpairs [-g] input=name output=name  [arc_layer=string]
[node_layer=string]   [cats=range]   [where=sql_query]
[arc_column=name]   [arc_backward_column=name]   [node_column=string]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

πŸŽ€ Flags πŸŽ€

  • -g β€” use a geodesic calculation for longitude-latitude projects. it's giving "i respect the curve of the earth" 🌍
  • --overwrite β€” allow output files to overwrite existing files. pls be careful, it rly does just go for it πŸ’€
  • --help β€” print usage summary 🫢
  • --verbose β€” verbose module output. it WILL yap πŸ—£οΈ
  • --quiet β€” quiet module output. it will NOT yap 🀫
  • --ui β€” force launching the GUI dialog ✨

🌸 Parameters 🌸

  • input=name [required] β€” name of input vector map. or, alternatively, a data source for direct OGR access 🌈
  • output=name [required] β€” name for output vector map πŸŽ€
  • arc_layer=string β€” arc layer. JSYK, vector features can have category values in different layers, and this number decides which layer to use. when you're doing direct OGR access, this is the layer name instead. Default: 1 πŸ’…
  • node_layer=string β€” node layer. same whole deal as above: vector features have category values in different layers and this number picks which one. with direct OGR access, it's the layer name. Default: 2 πŸ¦‹
  • cats=range β€” category values. Example: 1,3,7-9,13 ⭐
  • where=sql_query β€” WHERE conditions of the SQL statement, without the where keyword itself. Example: income < 1000 and population >= 10000 πŸ”₯
  • arc_column=name β€” arc forward/both direction(s) cost column (number) πŸ’œ
  • arc_backward_column=name β€” arc backward direction cost column (number) πŸ’œ
  • node_column=string β€” node cost column (number) πŸ’œ

πŸ’« DESCRIPTION πŸ’«

v.net.allpairs computes the shortest path between each selected node and all the other selected nodes. periodt. the output is a vector map containing the selected nodes and the shortest paths. it's giving "i did the math so you don't have to" 🧚


πŸ‘‘ NOTES πŸ‘‘

so here's the tea: an attribute table gets created and linked to layer arc_layer. that table has four columns:

  • cat
  • from_cat
  • to_cat
  • cost

each cat entry is the category of the shortest path going from the node with category from_cat to the node with category to_cat. πŸ’–

and if points are specified via the cats, layer, or where parameters, then the table is filled only for the selected points. no extras, no filler, we're being selective ✨

one more thing bestie: if arc_backward_column is not given, then (and yes, the original says "then then", we keep it real here) the same costs are used for forward and backward arcs. symmetric vibes only πŸ¦‹


🌸 EXAMPLE 🌸

find the shortest path along roads from selected archsites (the Spearfish sample dataset):

# prepare network: connect archsites to roads with threshold 200
v.net input=roads@PERMANENT points=archsites@PERMANENT \
output=roads_net operation=connect thresh=200
# verify result
v.category input=roads_net option=report
# only lines should have a category in layer 1
# only points should have a category in layer 2
# shortest path between all points with categories 1 - 5 in layer 2
v.net.allpairs input=roads_net cats=1-5 out=roads_net_all
v.db.select roads_net_all

result in matrix form:

from\to   1         3         4         5
1    0         18820.386 17206.651 17373.274
3    18820.386 0         1739.079  9040.575
4    17206.651 1739.079  0         7426.84
5    17373.274 9040.575  7426.84        0

look at that little matrix. she's beautiful. πŸ₯Ήβœ¨


🫢 SEE ALSO 🫢

v.net.path, v.net.distance β€” go read these too, they're the friend group πŸ’…


🌈 AUTHORS 🌈

  • Daniel Bundala, Google Summer of Code 2009, Student
  • Wolf Bergenheim, Mentor
  • Markus Metz

πŸŽ€ SOURCE CODE πŸŽ€

Available at: v.net.allpairs source code (history)

Latest change: Friday May 09 14:33:40 2025 in commit: b356c7e108fcbeca77474c8e83ebec8f1e7b3e4a

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual


okay that's the whole thing bestie, ily, go map some networks πŸ’–βœ¨ this was v.net.allpairs(1grass) from the GRASS 8.5.0 Reference Manual πŸŽ€πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from