Last active
December 6, 2019 20:55
-
-
Save reikoNeko/8f0a21b78854621d74b618637fdbb8f8 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 | |
universe = nx.DiGraph() | |
for line in progdata: | |
# use elements in list directly, rather than placeholders | |
universe.add_edge(*line.split(')') ) | |
paths = dict(nx.all_pairs_shortest_path_length(universe)) | |
center = list(nx.topological_sort(universe))[0] | |
print(center) | |
total=0 | |
for M in list(universe.nodes()): | |
total += paths[center][M] | |
print(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment