从 Python 中的随机图中获取邻接矩阵
Getting adjacency matrix from random graph in Python
以下代码生成一个随机图。如何获得每个图的邻接矩阵?
import networkx as nx
n = 10
p = 0.9
G = nx.generators.random_graphs.gnp_random_graph(n, p)
nx.draw(G)
见here:
A = nx.adjacency_matrix(G)
A.toarray()
以下代码生成一个随机图。如何获得每个图的邻接矩阵?
import networkx as nx
n = 10
p = 0.9
G = nx.generators.random_graphs.gnp_random_graph(n, p)
nx.draw(G)
见here:
A = nx.adjacency_matrix(G)
A.toarray()