grid_graph(dim, periodic=False)
The dimension n is the length of the list :None:None:`dim`
and the size in each dimension is the value of the corresponding list element.
'dim' is a tuple or list with, for each dimension, either a number that is the size of that dimension or an iterable of nodes for that dimension. The dimension of the grid_graph is the length of :None:None:`dim`
.
If periodic
is True, all dimensions are periodic. If False all dimensions are not periodic. If periodic
is iterable, it should yield :None:None:`dim`
bool values each of which indicates whether the corresponding axis is periodic.
The (possibly periodic) grid graph of the specified dimensions.
Returns the n-dimensional grid graph.
To produce a 2 by 3 by 4 grid graph, a graph on 24 nodes:
>>> from networkx import grid_graph
... G = grid_graph(dim=(2, 3, 4))
... len(G) 24
>>> G = grid_graph(dim=(range(7, 9), range(3, 6)))See :
... len(G) 6
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.shortest_paths.astar.astar_path
networkx.generators.lattice.grid_graph
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them