Skip to content

Instantly share code, notes, and snippets.

@niroyb
niroyb / IncreasingCostMST_Generator.py
Last active March 23, 2023 10:07
Searches a graph and yields all the minimum spanning trees in order of increasing cost. This could be used to solve minimum spanning trees with constraints by yielding trees until we reach the first one which satisfies a constraint. For example it could solve the degree constrained minimum spanning tree DCMST
#!/Usr/bin/env python
# -*- coding: utf-8 -*-
'''
Searches a graph and yields all the minimum spanning trees in order of increasing cost.
This could be used to solve minimum spanning trees with constraints by yielding trees until
we reach the first one which satisfies a constraint.
For example it could solve the degree constrained minimum spanning tree DCMST
'''
@skyscribe
skyscribe / .gdbinit
Created October 30, 2012 03:04
GDB init file to print STL containers and data members
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@hrldcpr
hrldcpr / tree.md
Last active June 19, 2025 08:17
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@wladston
wladston / dcmst.py
Created March 5, 2012 23:07
Degree constrained minimum spanning tree with networkx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# This is the framework for graphs we use on this work
import networkx as nx
# Tool to determine wether elements are on the same set
from networkx.utils import UnionFind
# We need this in python to "clone" objects
import copy