本文整理汇总了Python中graphillion.GraphSet.graph_size方法的典型用法代码示例。如果您正苦于以下问题:Python GraphSet.graph_size方法的具体用法?Python GraphSet.graph_size怎么用?Python GraphSet.graph_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphillion.GraphSet
的用法示例。
在下文中一共展示了GraphSet.graph_size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unary_operators
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import graph_size [as 别名]
def test_unary_operators(self):
gs = GraphSet([g0, g1, g12, g123, g1234, g134, g14, g4])
self.assertTrue(isinstance(~gs, GraphSet))
self.assertEqual(~gs, GraphSet([g124, g13, g2, g23, g234, g24, g3, g34]))
self.assertTrue(isinstance(gs.smaller(3), GraphSet))
self.assertEqual(gs.smaller(3), GraphSet([g0, g1, g12, g14, g4]))
self.assertTrue(isinstance(gs.larger(3), GraphSet))
self.assertEqual(gs.larger(3), GraphSet([g1234]))
self.assertTrue(isinstance(gs.graph_size(3), GraphSet))
self.assertEqual(gs.graph_size(3), GraphSet([g123, g134]))
self.assertTrue(isinstance(gs.len(3), GraphSet))
self.assertEqual(gs.len(3), GraphSet([g123, g134]))
gs = GraphSet([g12, g123, g234])
self.assertTrue(isinstance(gs.minimal(), GraphSet))
self.assertEqual(gs.minimal(), GraphSet([g12, g234]))
self.assertTrue(isinstance(gs.maximal(), GraphSet))
self.assertEqual(gs.maximal(), GraphSet([g123, g234]))
gs = GraphSet([g12, g14, g23, g34])
self.assertTrue(isinstance(gs.blocking(), GraphSet))
self.assertEqual(
gs.blocking(), GraphSet([g123, g1234, g124, g13, g134, g234, g24]))
示例2: grid_prob
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import graph_size [as 别名]
sum += 1.0
return sum
#m列n行の格子を左上から右下にあるくこととする
#下に移動する可能性をp,下に向かう可能性をqとする
m = 2
n = 2
p = 0.2
q = 0.8
lp = math.log10(p)
lq = math.log10(q)
mn = m+n
goal = (m+1)*(n+1)
universe= grid_prob(m, n, p=lp, q=lq)
GraphSet.set_universe(universe)
Gu = GraphSet({})
Gt = Gu.graph_size(mn)
Gs = Gt.paths(1, goal)
weight = prob_dict(universe)
for i in Gs.max_iter(weight):
wt = sumWeight(i, weight)
print 10**wt
print i
示例3: GraphSet
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import graph_size [as 别名]
# -*- coding: utf-8 -*-
from graphillion import GraphSet
import graphillion.tutorial as tl
n=15
m=10
nm = n+m
goal = (n+1)*(m+1)
universe=tl.grid(n,m)
GraphSet.set_universe(universe)
Gt=GraphSet.paths(1,goal)
Gs=Gt.graph_size(nm)
Guniv = GraphSet({})
Gss = Guniv.graph_size(nm)
Gs2 = Gss.paths(1,goal)
len(Gs)
len(Gs2)
示例4: GraphSet
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import graph_size [as 别名]
from graphillion import GraphSet
import graphillion.tutorial as tl
n=6
m=6
nm = n+m
goal = (n+1)*(m+1)
universe=tl.grid(n,m)
GraphSet.set_universe(universe)
Gt=GraphSet.paths(1,goal)
Gs=Gt.graph_size(nm)
Guniv = GraphSet({})
GsS = Guniv.graph_size(nm)
GsSP = GsS.paths(1,goal)
print len(GsS)
print len(GsSP)
Gss = []
GsSP = []
GsP = Guniv.paths(1,goal)
GsPS = GsP.graph_size(nm)
print len(GsP)
print len(GsPS)