Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- G = nx.Graph()
- positions = {}
- coordinates = [
- [0, 4],
- [-4, 3],
- [4, 3],
- [-6, 2],
- [-2, 2],
- [2, 2],
- [6, 2],
- [-7, 1],
- [-5, 1],
- [-3, 1],
- [-1, 1],
- [1, 1],
- [3, 1],
- [5, 1],
- [7, 1],
- [4, 0],
- [6, 0],
- [8, 0]
- ]
- parents = [0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 13, 14, 14]
- for index in range(len(parents)):
- G.add_node(index)
- G.add_edge(index, parents[index])
- positions[index] = coordinates[index]
- nx.draw(G, positions, node_size = 1000)
- labels = {
- 0: '0',
- 1: '1',
- 2: '2',
- 3: '3',
- 4: '4',
- 5: '5',
- 6: '6',
- 7: 'tx1',
- 8: 'tx2',
- 9: 'tx3',
- 10: 'tx4',
- 11: 'tx5',
- 12: 'tx6',
- 13: '13',
- 14: '14',
- 15: 'tx7',
- 16: 'tx8',
- 17: 'tx9'
- }
- nx.draw_networkx_labels(G, positions, labels = labels)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement