Professional Documents
Culture Documents
Shahidrehman
Shahidrehman
Z = [
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 0],
[1, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0]
]
G = nx.from_numpy_matrix(np.array(Z), create_using=nx.DiGraph())
[
G.add_node(k) for k in [1,2,3,4]]
G.add_edge(2,1)
G.add_edge(3,1)
G.add_edge(4,1)
ppr1 = nx.pagerank(G,personalization={1:1, 2:1, 3:1, 4:1})
print("The PageRank is:")
print(ppr1)
pos = nx.circular_layout(G)
nx.draw_circular(G)
labels = {i : i + 1 for i in G.nodes()}
nx.draw_networkx_labels(G, pos, labels, font_size=18)
plt.show()