Reputation:
I am plotting a directed graph in python using networkx and matplotlib. However, not all edges are visible. The nodes are so close to each other that it doesn't show a path between two nodes.
Code:
import networkx as nx
resultNodes = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9']
resultEdges = [('P0', 'P4'), ('P0', 'P2'), ('P0', 'P1'), ('P1', 'P7'), ('P1', 'P8'),
('P1', 'P2'), ('P2', 'P3'), ('P4', 'P5'), ('P4', 'P6'), ('P5', 'P6'),
('P9', 'P2'), ('P9', 'P7'), ('P9', 'P1')]
G=nx.DiGraph()
G.add_nodes_from(resultNodes)
G.add_edges_from(resultEdges)
print("Nodes of graph: ")
print(G.nodes())
print("Edges of graph: ")
print(G.edges())
nx.draw(G,with_labels=True,font_size=15,node_color='yellowgreen',node_size=1000)
Upvotes: 2
Views: 2444