def getDtwDag(xSize, ySize):
    """Returns a DTW-style directed acyclic graph."""
    def isValid(node):
        i, j = node
        return 0 <= i < xSize and 0 <= j < ySize

    def getChildren(node):
        i, j = node
        possChildren = [(i + 1, j), (i + 1, j + 1), (i, j + 1)]
        children = filter(isValid, possChildren)
        return children

    childrenDict = dict()
    for i in range(xSize):
        for j in range(ySize):
            node = (i, j)
            childrenDict[node] = getChildren(node)

    startNode = (0, 0)
    assert isValid(startNode)

    return childrenDict, startNode