目前,我创建了一个图如下:
import networkx as nx
edges = []
for i in range (10):
edges.append((i,i+1))
edges += [(10,0), (1,10), (2,8), (3,7), (4,6), (4,10), (5,10)]
# create the graph
G = nx.Graph()
G.add_nodes_from([i for i in range (11)])
G.add_edges_from(edges)现在,我需要的是将随机数目的新节点连接到上述核心网的每个节点,根据幂律分布为=3。因此,我得到了一个具有幂律分布的新图(例如:15个节点):
s1 = nx.utils.powerlaw_sequence(15, 3) #15 nodes, power-law exponent 3
G1 = nx.expected_degree_graph(s1, selfloops=False)现在,如何将这个新图连接到上一个网络中的某个节点?尝试过add_nodes_from,但它们似乎覆盖了以前的节点,这很奇怪;我无法确定它们是否连接到某个节点。或者有什么直接的方法可以做到这一点?谢谢你帮我!
发布于 2019-11-22 11:45:03
https://stackoverflow.com/questions/58990510
复制相似问题