Skip to content

NeighborhoodGraph ​

The induced subgraph on the vertices within distance n of v (underlying graph).

Wolfram LanguageNeighborhoodGraph
NeighborhoodGraph(g, v)distance ≤1\leq 1 (v and its immediate neighbours).
NeighborhoodGraph(g, v, n)distance ≤n\leq n, by BFS on the underlying (direction-blind) graph.
Typed signatures
TypePackageApplies
(value, any, integer?) -> valuecombinatoricsalways

Domain: Collections

Examples

Basic #

Default radius 1 around the middle of a 7-vertex path

live ↗
InVertexList(NeighborhoodGraph(PathGraph(7),4))\mathrm{VertexList}(\mathrm{NeighborhoodGraph}(\mathrm{PathGraph}(7), 4))Out[3,4,5]\bigl\lbrack3, 4, 5\bigr\rbrack
live ↗
InVertexList(NeighborhoodGraph(PathGraph(7),4,2))\mathrm{VertexList}(\mathrm{NeighborhoodGraph}(\mathrm{PathGraph}(7), 4, 2))Out[2,3,4,5,6]\bigl\lbrack2, 3, 4, 5, 6\bigr\rbrack
About
Examples2
CrosswalkWolfram Language

See also: Subgraph, GraphDistance