Skip to content

Instantly share code, notes, and snippets.

View tonicanada's full-sized avatar

Antonio Cañada Momblant tonicanada

View GitHub Profile
keyword RGB hex value
black #000000
silver #c0c0c0
gray #808080
white #ffffff
maroon #800000
red #ff0000
purple #800080
fuchsia #ff00ff
green #008000
@tonicanada
tonicanada / example_of_vertex_permutation_graph.csv
Last active January 13, 2022 12:43
example_of_vertex_permutation_graph
g2_vertex_id transormed_to
1 1
2 3
3 5
4 2
5 4
test_case = [3, 5, 2, 4, 7, 8, 1, 6]
expected_result = [[1, 3, 2, 5, 7], [4], [6, 8]]
def first_idx_unseen(seen_array):
for i in range(len(seen_array)):
if seen_array[i] == False:
return i
# Bipartite graph K_13
graph_k13 = np.array([
[0, 0, 0, 1],
[0, 0, 0, 1],
[0, 0, 0, 1],
[1, 1, 1, 0]
])
k13_automorphisms = generate_automorphisms(graph_k13)
@tonicanada
tonicanada / brute_force_test_graph_isomorphism.py
Last active January 15, 2022 15:39
Brute-force python code to check isomorphism between graphs
import itertools
import numpy as np
def get_graph_order(adj_matrix):
if len(adj_matrix) != len(adj_matrix[0]):
return -1
else:
return len(adj_matrix)
# Function that receives a matrix adjacency and returns edge set
def edge_set(adj_matrix):
edge_set = []
for row in range(len(adj_matrix)):
for col in range(len(adj_matrix[0])):
if (list(np.sort([row, col])) not in edge_set):
if adj_matrix[row][col] == 1:
edge_set.append(list(np.sort([row, col])))
return sorted(edge_set)
def check_vertex_transitive(adj_matrix):
vertex_comb = list(itertools.permutations(range(len(adj_matrix)), 2))
automorphisms_perm = [
auto["perm_vertex"] for auto in generate_automorphisms(adj_matrix)
]
check = [None] * len(vertex_comb)
for pair_vertex_idx in range(len(vertex_comb)):
for auto_idx in range(len(automorphisms_perm)):
if automorphisms_perm[auto_idx][vertex_comb[pair_vertex_idx][
0]] == vertex_comb[pair_vertex_idx][1]:
@tonicanada
tonicanada / UN_Population_2019.csv
Created January 15, 2022 23:36
United Nations World Population Prospects 2019
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 76 columns, instead of 10. in line 2.
Country,Notes,Country code,Type,Parent code,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
China,9,156,Country/Area,906,554419,569909,582576,593366,603052,612242,621363,630678,640296,650213,660408,670953,682103,694339,708255,724219,742415,762581,784075,805986,827601,848760,869486,889485,908464,926241,942685,957891,972205,986132,1000089,1014022,1027949,1042431,1058172,1075589,1095014,1116095,1137724,1158357,1176884,1192897,1206711,1218817,1230020,1240921,1251636,1261996,1271982,1281515,1290551,1299130,1307352,1315304,1323085,1330776,1338409,1345994,1353569,1361169,1368811,1376498,1384206,1391883,1399454,1406848,1414049,1421022,1427648,1433784,1439324
India,,356,Country/Area,5501,376325,382377,388799,395544,4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.