Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/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 | |
''' |
# | |
# 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 |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/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 |