Skip to content

Instantly share code, notes, and snippets.

View mdmitry1's full-sized avatar
:atom:
🦁

Dmitry Messerman mdmitry1

:atom:
🦁
View GitHub Profile
#!/usr/bin/python3.12
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')
from re import search
from sys import version as python_version
#Workaround for matplotlib bug
if search('GCC UCRT', python_version): from PyQt5 import QtCore
from matplotlib import cm, pyplot as plt
@mdmitry1
mdmitry1 / Makefile
Last active December 12, 2025 10:51
Prime numbers calculation in C++, Cython an Python
MODULE=primes_cython
VER=14
EXT=cpython-3$(VER)-$(HOSTTYPE)-gnu.so
SO=$(MODULE).$(EXT)
%: %.cpp
g++ -O2 -o $@ $<
strip $@
%.$(EXT): %_setup.py %.pyx
python3.$(VER) $< build_ext -i
strip $@
#!/usr/bin/python3.12
'''
https://www.pythonguis.com/tutorials/qtableview-modelviews-numpy-pandas/
'''
from sys import argv, exit
from rich import print as rprint
from pandas import read_csv
from os import name as osname, popen
from os.path import realpath, basename, splitext, split
from re import sub
@mdmitry1
mdmitry1 / Makefile
Last active December 13, 2025 08:37
Disjoint set
MODULE=disjoint_set_c
VER=12
EXT=cpython-3$(VER)-$(HOSTTYPE)-gnu.so
SO=$(MODULE).$(EXT)
%.$(EXT): %_setup.py %.pyx
python3.$(VER) $< build_ext -i
strip $@
-rm -rf build
all: $(SO)
clean:
@mdmitry1
mdmitry1 / questionary_ex.py
Last active November 9, 2025 20:34
Example of using typer
#!/usr/bin/python3.12
import questionary
from questionary import Style
from rich.console import Console
console_256=Console(color_system="256")
fancy = Style([
('qmark', 'fg:#673ab7 bold'),
('question', 'bold'),
('answer', 'fg:#ff00ff bg:#ffffff nobold'),
('pointer', 'fg:#673ab7 bold'),
#!/usr/bin/python3.14
"""Query GitHub API"""
from datetime import datetime
from urllib.request import urlopen
from pprint import pformat
from sys import argv
import json
from os import popen
def user_time(login):
#!/usr/bin/python3.12
# coding: utf-8
# author: github.com/vuiseng9
# dependency ubt1804: graphviz libgraphviz-dev libgl1-mesa-glx
import os, sys
import pygraphviz
from glob import glob
from natsort import natsorted
from rich import print as rprint
.env
#!/usr/bin/python3.14
import arxiv,sh
from json import load, loads, dump, dumps, JSONDecodeError
from sys import argv
from os import makedirs, listdir, getcwd
from os.path import join, isdir, isfile, realpath, dirname
from typing import List, Tuple
from pydantic import RootModel
from operator import itemgetter
from rich import print as rprint

General Performance Comparison

VF2 advantages

VF2 tends to perform better on graphs that are sparse (fewer connections), small, or have a regular structure (e.g., 2D meshes or bounded valence graphs with low valence). In some cases, Nauty cannot find a solution for these regular graphs if they exceed a certain size (a few dozen nodes).

Nauty advantages

Nauty (via pynauty) is generally the better algorithm for dense or large randomly connected graphs.