Last active
October 2, 2016 06:42
-
-
Save nullset2/5c85da67b1bdedc38b3800958f5dfac4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import networkx as nx | |
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| def read_graph(): | |
| graph_adjacency_list = { } | |
| for line in open("input.txt"): | |
| line = map(int, line.rstrip("\t\r\n").split("\t")) | |
| graph_adjacency_list.update({ line[0]: { e: 1 for e in line[1:] } }) | |
| return graph_adjacency_list | |
| graph_data = read_graph() | |
| G = nx.Graph(graph_data) | |
| nx.draw_networkx(G, with_labels = True, node_color = "c", edge_color = "k", font_size = 8) | |
| plt.axis('off') | |
| plt.draw() | |
| plt.savefig("graph.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment