I have the next array:
DeleteCases[DiskMatrix[radius], 0, {2}]
And I would like to have access to each element first neighbors. How can I have access to those elements?
I have the next array:
DeleteCases[DiskMatrix[radius], 0, {2}]
And I would like to have access to each element first neighbors. How can I have access to those elements?
dm = DiskMatrix[3];
nzp = Position[dm, 1];
RelationGraph[ChessboardDistance[##] == 1 &, nzp,
VertexCoordinates -> nzp,
PlotTheme -> "VintageDiagram",
VertexSize -> {.35, .2},
ImageSize -> 1 -> 50]
Use ManhattanDistance[##] == 1 & in the first argument to get
Note: You can also define nzp as:
nzp = SparseArray[dm]["NonzeroPositions"];