亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? topological.py

?? SQLAlchemy. 經典的Python ORM框架。學習必看。
?? PY
字號:
# topological.py# Copyright (C) 2005, 2006, 2007, 2008 Michael Bayer mike_mp@zzzcomputing.com## This module is part of SQLAlchemy and is released under# the MIT License: http://www.opensource.org/licenses/mit-license.php"""Topological sorting algorithms.The topological sort is an algorithm that receives this list ofdependencies as a *partial ordering*, that is a list of pairs whichmight say, *X is dependent on Y*, *Q is dependent on Z*, but does notnecessarily tell you anything about Q being dependent on X. Therefore,its not a straight sort where every element can be compared toanother... only some of the elements have any sorting preference, andthen only towards just some of the other elements.  For a particularpartial ordering, there can be many possible sorts that satisfy theconditions."""from sqlalchemy import utilfrom sqlalchemy.exceptions import CircularDependencyError__all__ = ['sort', 'sort_with_cycles', 'sort_as_tree']def sort(tuples, allitems):    """sort the given list of items by dependency.        'tuples' is a list of tuples representing a partial ordering.    """        return [n.item for n in _sort(tuples, allitems, allow_cycles=False, ignore_self_cycles=True)]def sort_with_cycles(tuples, allitems):    """sort the given list of items by dependency, cutting out cycles.        returns results as an iterable of 2-tuples, containing the item,    and a list containing items involved in a cycle with this item, if any.        'tuples' is a list of tuples representing a partial ordering.    """        return [(n.item, [n.item for n in n.cycles or []]) for n in _sort(tuples, allitems, allow_cycles=True)]    def sort_as_tree(tuples, allitems, with_cycles=False):    """sort the given list of items by dependency, and return results    as a hierarchical tree structure.        returns results as an iterable of 3-tuples, containing the item,    and a list containing items involved in a cycle with this item, if any,    and a list of child tuples.          if with_cycles is False, the returned structure is of the same form    but the second element of each tuple, i.e. the 'cycles', is an empty list.        'tuples' is a list of tuples representing a partial ordering.    """    return _organize_as_tree(_sort(tuples, allitems, allow_cycles=with_cycles))class _Node(object):    """Represent each item in the sort."""    def __init__(self, item):        self.item = item        self.dependencies = util.Set()        self.children = []        self.cycles = None    def __str__(self):        return self.safestr()        def safestr(self, indent=0):        return (' ' * indent * 2) + \            str(self.item) + \            (self.cycles is not None and (" (cycles: " + repr([x for x in self.cycles]) + ")") or "") + \            "\n" + \            ''.join([str(n) for n in self.children])    def __repr__(self):        return "%s" % (str(self.item))    def all_deps(self):        """Return a set of dependencies for this node and all its cycles."""        deps = util.Set(self.dependencies)        if self.cycles is not None:            for c in self.cycles:                deps.update(c.dependencies)        return depsclass _EdgeCollection(object):    """A collection of directed edges."""    def __init__(self):        self.parent_to_children = {}        self.child_to_parents = {}    def add(self, edge):        """Add an edge to this collection."""        (parentnode, childnode) = edge        if parentnode not in self.parent_to_children:            self.parent_to_children[parentnode] = util.Set()        self.parent_to_children[parentnode].add(childnode)        if childnode not in self.child_to_parents:            self.child_to_parents[childnode] = util.Set()        self.child_to_parents[childnode].add(parentnode)        parentnode.dependencies.add(childnode)    def remove(self, edge):        """Remove an edge from this collection.        Return the childnode if it has no other parents.        """        (parentnode, childnode) = edge        self.parent_to_children[parentnode].remove(childnode)        self.child_to_parents[childnode].remove(parentnode)        if len(self.child_to_parents[childnode]) == 0:            return childnode        else:            return None    def has_parents(self, node):        return node in self.child_to_parents and len(self.child_to_parents[node]) > 0    def edges_by_parent(self, node):        if node in self.parent_to_children:            return [(node, child) for child in self.parent_to_children[node]]        else:            return []    def get_parents(self):        return self.parent_to_children.keys()    def pop_node(self, node):        """Remove all edges where the given node is a parent.        Return the collection of all nodes which were children of the        given node, and have no further parents.        """        children = self.parent_to_children.pop(node, None)        if children is not None:            for child in children:                self.child_to_parents[child].remove(node)                if not self.child_to_parents[child]:                    yield child    def __len__(self):        return sum([len(x) for x in self.parent_to_children.values()])    def __iter__(self):        for parent, children in self.parent_to_children.iteritems():            for child in children:                yield (parent, child)    def __str__(self):        return repr(list(self))    def __repr__(self):        return repr(list(self))def _sort(tuples, allitems, allow_cycles=False, ignore_self_cycles=False):    nodes = {}    edges = _EdgeCollection()    for item in list(allitems) + [t[0] for t in tuples] + [t[1] for t in tuples]:        if id(item) not in nodes:            node = _Node(item)            nodes[item] = node    for t in tuples:        if t[0] is t[1]:            if allow_cycles:                n = nodes[t[0]]                n.cycles = util.Set([n])            elif not ignore_self_cycles:                raise CircularDependencyError("Self-referential dependency detected " + repr(t))            continue        childnode = nodes[t[1]]        parentnode = nodes[t[0]]        edges.add((parentnode, childnode))    queue = []    for n in nodes.values():        if not edges.has_parents(n):            queue.append(n)    output = []    while nodes:        if not queue:            # edges remain but no edgeless nodes to remove; this indicates            # a cycle            if allow_cycles:                for cycle in _find_cycles(edges):                    lead = cycle[0][0]                    lead.cycles = util.Set()                    for edge in cycle:                        n = edges.remove(edge)                        lead.cycles.add(edge[0])                        lead.cycles.add(edge[1])                        if n is not None:                            queue.append(n)                    for n in lead.cycles:                        if n is not lead:                            n._cyclical = True                            for (n,k) in list(edges.edges_by_parent(n)):                                edges.add((lead, k))                                edges.remove((n,k))                continue            else:                # long cycles not allowed                raise CircularDependencyError("Circular dependency detected " + repr(edges) + repr(queue))        node = queue.pop()        if not hasattr(node, '_cyclical'):            output.append(node)        del nodes[node.item]        for childnode in edges.pop_node(node):            queue.append(childnode)    return outputdef _organize_as_tree(nodes):    """Given a list of nodes from a topological sort, organize the    nodes into a tree structure, with as many non-dependent nodes    set as siblings to each other as possible.        returns nodes as 3-tuples (item, cycles, children).    """    if not nodes:        return None    # a list of all currently independent subtrees as a tuple of    # (root_node, set_of_all_tree_nodes, set_of_all_cycle_nodes_in_tree)    # order of the list has no semantics for the algorithmic    independents = []    # in reverse topological order    for node in util.reversed(nodes):        # nodes subtree and cycles contain the node itself        subtree = util.Set([node])        if node.cycles is not None:            cycles = util.Set(node.cycles)        else:            cycles = util.Set()        # get a set of dependent nodes of node and its cycles        nodealldeps = node.all_deps()        if nodealldeps:            # iterate over independent node indexes in reverse order so we can efficiently remove them            for index in xrange(len(independents)-1,-1,-1):                child, childsubtree, childcycles = independents[index]                # if there is a dependency between this node and an independent node                if (childsubtree.intersection(nodealldeps) or childcycles.intersection(node.dependencies)):                    # prepend child to nodes children                    # (append should be fine, but previous implemetation used prepend)                    node.children[0:0] = [(child.item, [n.item for n in child.cycles or []], child.children)]                    # merge childs subtree and cycles                    subtree.update(childsubtree)                    cycles.update(childcycles)                    # remove the child from list of independent subtrees                    independents[index:index+1] = []        # add node as a new independent subtree        independents.append((node,subtree,cycles))    # choose an arbitrary node from list of all independent subtrees    head = independents.pop()[0]    # add all other independent subtrees as a child of the chosen root    # used prepend [0:0] instead of extend to maintain exact behaviour of previous implementation    head.children[0:0] = [(i[0].item, [n.item for n in i[0].cycles or []], i[0].children) for i in independents]    return (head.item, [n.item for n in head.cycles or []], head.children)def _find_cycles(edges):    involved_in_cycles = util.Set()    cycles = {}    def traverse(node, goal=None, cycle=None):        if goal is None:            goal = node            cycle = []        elif node is goal:            return True        for (n, key) in edges.edges_by_parent(node):            if key in cycle:                continue            cycle.append(key)            if traverse(key, goal, cycle):                cycset = util.Set(cycle)                for x in cycle:                    involved_in_cycles.add(x)                    if x in cycles:                        existing_set = cycles[x]                        [existing_set.add(y) for y in cycset]                        for y in existing_set:                            cycles[y] = existing_set                        cycset = existing_set                    else:                        cycles[x] = cycset            cycle.pop()    for parent in edges.get_parents():        traverse(parent)    # sets are not hashable, so uniquify with id    unique_cycles = dict([(id(s), s) for s in cycles.values()]).values()    for cycle in unique_cycles:        edgecollection = [edge for edge in edges                          if edge[0] in cycle and edge[1] in cycle]        yield edgecollection

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日夜夜精品视频免费| 久久在线观看免费| 欧美视频日韩视频在线观看| 欧洲av在线精品| 精品少妇一区二区三区在线播放| 久久久综合精品| 亚洲成人一区在线| youjizz国产精品| 欧美另类videos死尸| 91精品在线观看入口| 久久婷婷一区二区三区| 亚洲一区二区三区小说| 一本色道亚洲精品aⅴ| 欧美成人a在线| 精品一二三四区| 日韩一区二区三区视频| 日韩国产精品大片| 欧美巨大另类极品videosbest | 99re这里只有精品首页| 不卡大黄网站免费看| 欧美国产成人精品| 成人听书哪个软件好| 欧美亚洲国产bt| 中文字幕第一区二区| 日韩精品1区2区3区| 在线观看中文字幕不卡| 日韩欧美中文一区二区| 亚洲精品国产高清久久伦理二区| 中文字幕一区不卡| 91精品国产色综合久久不卡蜜臀 | 99re在线精品| 亚洲视频网在线直播| 国产精品一线二线三线| 久久精品亚洲麻豆av一区二区 | 欧美tickling挠脚心丨vk| 亚洲国产视频网站| 欧美无乱码久久久免费午夜一区 | 亚洲高清免费在线| 在线电影欧美成精品| 久久成人羞羞网站| 精品精品国产高清a毛片牛牛| 美女视频免费一区| 久久久综合网站| 日本道在线观看一区二区| 亚洲美女屁股眼交3| 欧美一级日韩免费不卡| 狠狠色丁香婷综合久久| 国产精品女同互慰在线看| aaa欧美大片| 国精产品一区一区三区mba视频| 欧美美女一区二区三区| 久久不见久久见免费视频1| 国产精品人人做人人爽人人添| 一本大道久久a久久综合婷婷| 亚洲成人一区二区在线观看| 日韩一区二区精品在线观看| 精品一区二区三区视频在线观看| 久久综合资源网| 六月婷婷色综合| 亚洲综合色婷婷| 国产三级一区二区| 欧洲另类一二三四区| 国产成人精品免费网站| 五月天欧美精品| 亚洲免费资源在线播放| 国产亚洲午夜高清国产拍精品| 91黄色激情网站| 成人免费观看视频| 韩国成人在线视频| 奇米色777欧美一区二区| 一区二区三区精密机械公司| 国产精品二区一区二区aⅴ污介绍| 7777精品伊人久久久大香线蕉完整版 | 欧美日韩国产精品自在自线| 91麻豆免费在线观看| 成人黄页在线观看| 色婷婷av一区二区三区gif | 欧美日韩国产区一| 欧美日韩激情一区| 久久九九国产精品| 亚洲欧美区自拍先锋| 中文字幕亚洲在| 欧美r级电影在线观看| 国产日韩影视精品| 美女免费视频一区二区| 日本中文一区二区三区| 美国三级日本三级久久99 | 岛国av在线一区| 成人黄色片在线观看| 国产高清不卡一区二区| 成人精品视频网站| 成人av免费在线| 欧美情侣在线播放| 欧美精品一区二区三区蜜臀| 亚洲国产岛国毛片在线| 一级做a爱片久久| 男男成人高潮片免费网站| 免费成人在线观看| 成人免费毛片a| 91福利资源站| 精品奇米国产一区二区三区| 国产精品久久三区| 免费久久99精品国产| 成人免费黄色大片| 日韩欧美中文字幕一区| 亚洲欧美色图小说| 国产高清不卡二三区| 91精品国产高清一区二区三区蜜臀| 国产人成一区二区三区影院| 亚洲一区二区三区四区在线免费观看| 天堂资源在线中文精品| 国产91在线观看丝袜| 91精品国产综合久久久久久久 | 日韩国产欧美在线观看| 成年人网站91| 日本一区二区视频在线| 免费精品99久久国产综合精品| 99久久国产综合精品麻豆| 日韩精品一区二区三区中文不卡| 亚洲精品午夜久久久| 成人综合激情网| 精品捆绑美女sm三区| 天天亚洲美女在线视频| 欧美丰满少妇xxxbbb| 亚洲伊人色欲综合网| 欧美性淫爽ww久久久久无| 一区二区三区91| 欧美性色欧美a在线播放| 自拍偷自拍亚洲精品播放| 97精品久久久午夜一区二区三区 | 国产一区二区电影| 国产精品午夜春色av| 成人精品电影在线观看| 依依成人综合视频| 精品视频资源站| 久久99精品久久久久| 亚洲一区视频在线| 久久久精品一品道一区| 91色porny在线视频| 免费成人av在线播放| 国产精品视频一二三| 欧美亚洲综合色| 久久国产成人午夜av影院| 中文字幕欧美日韩一区| 在线影院国内精品| 激情综合色播激情啊| 亚洲美女在线一区| 26uuu精品一区二区在线观看| 国产精一区二区三区| 偷拍一区二区三区| 亚洲乱码中文字幕| 亚洲精品在线观看视频| 欧美亚洲一区二区在线| 91免费国产视频网站| 国产精品88888| 九九**精品视频免费播放| 亚洲一区二区黄色| 椎名由奈av一区二区三区| 精品国产免费一区二区三区香蕉 | 亚洲欧洲性图库| 国产亚洲精品aa午夜观看| 这里只有精品视频在线观看| 91成人在线精品| 91视频www| 91传媒视频在线播放| 91天堂素人约啪| 99久精品国产| 91精品福利视频| 欧美午夜免费电影| 欧美丝袜自拍制服另类| 91久久久免费一区二区| 91年精品国产| 欧美在线一区二区| 欧美精品一卡二卡| 欧美一级夜夜爽| 日韩美女在线视频| 国产欧美日韩综合精品一区二区| 国产校园另类小说区| 国产精品久久久久久久久快鸭 | 欧美日韩日日骚| 久久综合色之久久综合| 久久九九久久九九| 亚洲国产视频在线| 狠狠色丁香久久婷婷综合_中| 国产精品一区免费在线观看| 国产iv一区二区三区| 91国偷自产一区二区使用方法| 欧美高清激情brazzers| 久久亚洲免费视频| 亚洲成人www| 成人午夜短视频| 4438成人网| 亚洲婷婷综合久久一本伊一区| 亚洲成av人片一区二区| 国产.精品.日韩.另类.中文.在线.播放| 成人一二三区视频| 日韩一级大片在线观看| 亚洲免费av高清| 国产91在线观看| 精品国产成人在线影院|