Skip to content

Instantly share code, notes, and snippets.

View mirrornerror's full-sized avatar

mirrornerror mirrornerror

  • Japan
View GitHub Profile
@mirrornerror
mirrornerror / embed_animation.ipynb
Last active November 6, 2019 08:26
Matplotlib Animation embed on Web page
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mirrornerror
mirrornerror / TSP_BIT_DP.ipynb
Last active April 20, 2023 14:38
TSP bit DP
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mirrornerror
mirrornerror / TSP_DP.ipynb
Last active April 20, 2023 14:38
TSP DP
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from tqdm import tqdm_notebook as tqdm
def min_matching(edges):
# Find odd-degree nodes in MST
odd = []
for i in range(num):
cnt = 0
for e in sum(edges, []):
if i == e:
cnt += 1
@mirrornerror
mirrornerror / MST_Euler.ipynb
Last active April 20, 2023 14:38
TSP/MST_Euler.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mirrornerror
mirrornerror / kruskal_prim_MST.ipynb
Created February 5, 2019 17:36
Kruskal Prim Algorithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from tqdm import tqdm_notebook as tqdm
pbar = tqdm(total=10)
for i in range(10):
pbar.update(1)
pbar.close()
@mirrornerror
mirrornerror / print_end_option.py
Created February 2, 2019 15:37
print end option
for i in range(5):
print(i)
# output:
# 0
# 1
# 2
# 3
# 4
# print end option
# pyconcorde: https://github.com/jvkersch/pyconcorde
from concorde.tsp import TSPSolver
num=30
X = np.random.random(num)*10**6
Y = np.random.random(num)*10**6
solver = TSPSolver.from_data(X, Y, norm='EUC_2D')
solution = solver.solve()
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))