Example #1
0
    res = 0

    for i in xrange(1, t+1):
        binom = 1

        for j in xrange(1, i+1):
            binom *= (c - i + j)
            binom /= j

        res += binom

    return res
# end def


CtdColor = recordtype('CtdColor', 'isInSet number nodes')

# bool isInSet: for each color, save whether the color is in the combination
# int  number:  store the frequency of each color
# set<int> nodes


CtdData = recordtype('CtdData', 'numColors treeDepth currentDepth combi ' +
                     'lastColor responsible color unionFind max_id')

# int numColors:          number of all colors, whose frequency are at least 2
# int treeDepth:          the tree depth, which is checked
# int currentDepth:       current number of colors in the combination
# set<int> combi:         store the colors, which are in the combination,
#                             without the last color
# int lastColor:          store the last color, which is in the combination
Example #2
0
#


import sys
import os
from lib.graph.graph import Graph, Coloring
from lib.util.recordtype import *
import itertools

# Define a record type of information about the vertices
# Attributes:
#     parent:  vertex that is the parent in the decomposition.  None iff vertex
#         is the root
#     children:  list of vertices that are children of this vertex
#     depth:  integer of the depth of the vertex.  Root has depth 0.
VertexInfo = recordtype('VertexInfo', 'parent children depth')


class TDDecomposition(Graph):
    """
    A subclass of Graph with additional data structures to describe a
    treedepth decomposition.

    Attributes:
        maxDepth:  The depth of the decomposition
        vertexRecords:  A dictionary mapping a vertex to its VertexInfo
            record (see above)
        root:  the root of the decomposition
    """

    def __init__(self):