I have to create a lattice graph of dimensions mxn.
In networkx I would do the following:
N = 5
M = 4
G = nx.generators.lattice.grid_2d_graph(N,M, periodic=True)
and I would expect a networkx.graph object as a result.
The problem is that, if I call for instance
G.nodes
It does not print the list of nodes as a vector. For instance, if I, instead of using grid_2d_graph, would have used:
G = nx.erdos_renyi_graph(int(N),0.3)
print G.nodes
I would have got a list of numbers
[0,1,2,3,4...,N]
In case of the lattice graph instead I got:
[(0, 1), (1, 2), (3, 2), (0, 0), (3, 3), (3, 0), (3, 1), (2, 1), (0, 2), (2, 0), (1, 3), (2, 3), (4, 3), (2, 2), (1, 0), (4, 2), (0, 3), (4, 1), (1, 1), (4, 0)]
which is like a Matrix.
I would like to get a vector of nodes (as in the other case) and the adjacency matrix of this graph. What can I do?