'Getting adjacency matrix from random graph in Python

The following code generates a random graph. How do I obtain adjacency matrix for each graph?

import networkx as nx

n = 10
p = 0.9

G = nx.generators.random_graphs.gnp_random_graph(n, p)
nx.draw(G)


Solution 1:[1]

See here:

A = nx.adjacency_matrix(G)
A.toarray()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mcsoini