当前位置: 首页>>代码示例>>Python>>正文


Python pygraph.digraph函数代码示例

本文整理汇总了Python中pygraph.digraph函数的典型用法代码示例。如果您正苦于以下问题:Python digraph函数的具体用法?Python digraph怎么用?Python digraph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了digraph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testAddEmptyGraph

 def testAddEmptyGraph(self):
     gr1 = pygraph.digraph()
     gr1.generate(25, 100)
     gr1c = copy.copy(gr1)
     gr2 = pygraph.digraph()
     gr1.add_graph(gr2)
     self.assertTrue(gr1.nodes() == gr1c.nodes())
     self.assertTrue(gr1.edges() == gr1c.edges())
开发者ID:svn2github,项目名称:python-graph2,代码行数:8,代码来源:unittests-digraph.py

示例2: testAddGraph

 def testAddGraph(self):
     gr1 = pygraph.digraph()
     gr1.generate(25, 100)
     gr2 = pygraph.digraph()
     gr2.generate(40, 200)
     gr1.add_graph(gr2)
     for each in gr2.nodes():
         self.assertTrue(each in gr1)
     for each in gr2.edges():
         self.assertTrue(each in gr1.edges())
开发者ID:svn2github,项目名称:python-graph2,代码行数:10,代码来源:unittests-digraph.py

示例3: graphize

  def graphize(self):
    try:
      self.graph = pygraph.digraph()
    except (NameError, AttributeError):
      self.graph = digraph()   

    modules = [self.topModule] + self.moduleList
    # first, we must add all the nodes. Only then can we add all the edges
    self.graph.add_nodes(modules)

    # here we have a strictly directed graph, so we need only insert directed edges
    for module in modules:
      def checkParent(child):
        if module.name == child.parent:
          return True
        else:
          return False

      children = filter(checkParent, modules)
      for child in children:
        # due to compatibility issues, we need these try catch to pick the 
        # right function prototype.
        try:
          self.graph.add_edge(module,child) 
        except TypeError:
          self.graph.add_edge((module,child)) 
开发者ID:sunila,项目名称:airblue_7dec12,代码行数:26,代码来源:ModuleList.py

示例4: graphizeSynth

  def graphizeSynth(self):
    try:
      self.graphSynth = pygraph.digraph()
    except (NameError, AttributeError):
      self.graphSynth = digraph()
    modulesUnfiltered = [self.topModule] + self.moduleList
    # first, we must add all the nodes. Only then can we add all the edges
    # filter by synthesis boundaries
    modules = filter(checkSynth, modulesUnfiltered)
    self.graphSynth.add_nodes(modules)

    # here we have a strictly directed graph, so we need only insert directed edges
    for module in modules:
      def checkParent(child):
        if module.name == child.synthParent:
          return True
        else:
          return False

      children = filter(checkParent, modules)
      for child in children:
        #print "Adding p: " + module.name + " c: " + child.name
        try:
          self.graphSynth.add_edge(module,child) 
        except TypeError:
          self.graphSynth.add_edge((module,child)) 
开发者ID:sunila,项目名称:airblue_7dec12,代码行数:26,代码来源:ModuleList.py

示例5: sort_out_covering_exons

def sort_out_covering_exons (cursor, exons):

    # havana is manually curated and gets priority
    is_ensembl = {}
    is_havana  = {}
    for exon in exons:
        logic_name = get_logic_name(cursor, exon.analysis_id)
        is_ensembl[exon] = ('ensembl' in logic_name)
        is_havana [exon] = ('havana'  in logic_name)

    dg = digraph()
    dg.add_nodes(exons)
    for exon1, exon2 in combinations(dg.nodes(),2):
        master, covered = find_master(cursor, exon1,exon2,is_ensembl,is_havana)
        if master is not None and covered is not None:
            dg.add_edge(master,covered)
    assert not find_cycle(dg)
    clusters = dict(((k,v) for k,v in accessibility(dg).iteritems()
                     if not dg.incidents(k)))
    for k in clusters:
        clusters[k].remove(k)

    for master_exon, covered_list in clusters.iteritems():
        master_exon.covering_exon       = -1 # nobody's covering this guy
        master_exon.covering_exon_known = -1 # formal
        for covered_exon in covered_list:
            covered_exon.covering_exon       = master_exon.exon_id
            covered_exon.covering_exon_known = master_exon.is_known
开发者ID:ivanamihalek,项目名称:exolocator,代码行数:28,代码来源:06_exon_coordinates.py

示例6: testSanityDigraph

 def testSanityDigraph(self):
     G = pygraph.digraph()
     G.generate(100, 500)
     st, lo = G.breadth_first_search()
     for each in G:
         if (st[each] != None):
             assert lo.index(each) > lo.index(st[each])
开发者ID:svn2github,项目名称:python-graph2,代码行数:7,代码来源:unittests-searching.py

示例7: testDigraph

 def testDigraph(self):
     
     def has_parent(node, list):
         for each in list:
             if gr.has_edge(each, node):
                 return True
         return (ts == [])
         
     gr = pygraph.digraph()
     gr.add_nodes([0,1,2,3,4,5,6,7,8])
     gr.add_edge(0,1)
     gr.add_edge(0,2)
     gr.add_edge(1,3)
     gr.add_edge(1,4)
     gr.add_edge(2,5)
     gr.add_edge(2,6)
     gr.add_edge(3,7)
     gr.add_edge(8,0)
     gr.add_edge(7,5)
     gr.add_edge(3,0)
     gr.add_edge(4,3)
     gr.add_edge(2,7)
     gr.add_edge(6,0)
     ts = topological_sorting(gr)
     while (ts):
         x = ts.pop()
         assert has_parent(x, ts)
开发者ID:svn2github,项目名称:python-graph2,代码行数:27,代码来源:unittests-sorting.py

示例8: testReadDigraphDot

 def testReadDigraphDot(self):
     dot = ['digraph graphname {', '1;', '2;', '3;', '4;', '5;', '1 -> 2;', '4 -> 5;', '1 -> 5;', '2 -> 3;', '2 -> 4;', '3 -> 5;', '}', '']
     dot = "\n".join(dot)
     gr = pygraph.digraph()
     gr.read(dot, 'dot')
     self._check_nodes(gr, dot)
     self._check_arrows(gr, dot)
开发者ID:svn2github,项目名称:python-graph2,代码行数:7,代码来源:unittests-readwrite.py

示例9: testGraphComplete

 def testGraphComplete(self):
     gr = pygraph.digraph()
     gr.add_nodes(xrange(10))
     gr.complete()
     for i in xrange(10):
         for j in range(10):
             self.assertTrue((i, j) in gr.edges() or i == j)
开发者ID:svn2github,项目名称:python-graph2,代码行数:7,代码来源:unittests-digraph.py

示例10: testNoCycleDigraph2

 def testNoCycleDigraph2(self):
     G = pygraph.digraph()
     G.add_nodes([1,2,3])
     G.add_edge(1,2)
     G.add_edge(1,3)
     G.add_edge(2,3)
     assert G.find_cycle() == []
开发者ID:svn2github,项目名称:python-graph2,代码行数:7,代码来源:unittests-cycles.py

示例11: testGraphInverse

 def testGraphInverse(self):
     gr = pygraph.digraph()
     gr.generate(50, 300)
     inv = gr.inverse()
     for each in gr.edges():
         self.assertTrue(each not in inv.edges())
     for each in inv.edges():
         self.assertTrue(each not in gr.edges())
开发者ID:svn2github,项目名称:python-graph2,代码行数:8,代码来源:unittests-digraph.py

示例12: testRandomGraph

 def testRandomGraph(self):
     gr = pygraph.digraph()
     gr.generate(100, 500)
     self.assertEqual(gr.nodes(), range(100))
     self.assertEqual(len(gr.edges()), 500)
     for each, other in gr.edges():
         self.assertTrue(each in gr)
         self.assertTrue(other in gr)
开发者ID:svn2github,项目名称:python-graph2,代码行数:8,代码来源:unittests-digraph.py

示例13: testNodeRemoval

 def testNodeRemoval(self):
     gr = pygraph.digraph()
     gr.generate(10, 90)
     gr.del_node(0)
     self.assertTrue(0 not in gr)
     for each, other in gr.edges():
         self.assertTrue(each in gr)
         self.assertTrue(other in gr)
开发者ID:svn2github,项目名称:python-graph2,代码行数:8,代码来源:unittests-digraph.py

示例14: testNoCycleDigraph

 def testNoCycleDigraph(self):
     G = pygraph.digraph()
     G.add_nodes([1, 2, 3, 4, 5])
     G.add_edge(1, 2)
     G.add_edge(2, 3)
     G.add_edge(2, 4)
     G.add_edge(4, 5)
     G.add_edge(3, 5)
     assert G.find_cycle() == []
开发者ID:svn2github,项目名称:python-graph2,代码行数:9,代码来源:unittests-cycles.py

示例15: testMisleadingDigraph

 def testMisleadingDigraph(self):
     G = pygraph.digraph()
     G.add_nodes([1, 2, 3, 4, 5])
     G.add_edge(1, 2)
     G.add_edge(2, 3)
     G.add_edge(2, 4)
     G.add_edge(4, 5)
     G.add_edge(3, 5)
     G.add_edge(3, 1)
     assert G.find_cycle() == [1, 2, 3]
开发者ID:svn2github,项目名称:python-graph2,代码行数:10,代码来源:unittests-cycles.py


注:本文中的pygraph.digraph函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。