def spanning_2d_grid(length):
ret = nx.grid_2d_graph(length + <NUM_LIT:2>, length)<EOL>for i in range(length):<EOL><INDENT>ret.node[(<NUM_LIT:0>, i)]['<STR_LIT>'] = <NUM_LIT:0><EOL>ret[(<NUM_LIT:0>, i)][(<NUM_LIT:1>, i)]['<STR_LIT>'] = <NUM_LIT:0><EOL>ret.node[(length + <NUM_LIT:1>, i)]['<STR_LIT>'] = <NUM_LIT:1><EOL>ret[(length + <NUM_LIT:1>, i)][(length, i)]['<STR_LIT>'] = <NUM_LIT:1><EOL><DEDENT>return ret<EOL>
Generate a square lattice with auxiliary nodes for spanning detection

Parameters
----------

length : int
   Number of nodes in one dimension, excluding the auxiliary nodes.

Returns
-------

networkx.Graph
   A square lattice graph with auxiliary nodes for spanning cluster
   detection

See Also
--------

sample_states : spanning cluster detection