本文整理汇总了Python中graphillion.GraphSet.including方法的典型用法代码示例。如果您正苦于以下问题:Python GraphSet.including方法的具体用法?Python GraphSet.including怎么用?Python GraphSet.including使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphillion.GraphSet
的用法示例。
在下文中一共展示了GraphSet.including方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_binary_operators
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import including [as 别名]
#.........这里部分代码省略.........
self.assertEqual(gs, GraphSet([g0, g3, g34]))
gs = GraphSet(u)
gs.quotient_update(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g3, g34]))
gs = GraphSet(u) % GraphSet(v)
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g134, g14, g4]))
gs = GraphSet(u).remainder(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g134, g14, g4]))
gs = GraphSet(u)
gs %= GraphSet(v)
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g134, g14, g4]))
gs = GraphSet(u)
gs.remainder_update(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g134, g14, g4]))
gs = GraphSet(u).complement()
self.assertEqual(gs, GraphSet([g0, g123, g1234, g2, g23, g234, g34, g4]))
v = [g12, g14, g23, g34]
gs = GraphSet(u).join(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(
gs, GraphSet([g12, g123, g124, g1234, g134, g14, g23, g234, g34]))
gs = GraphSet(u).meet(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g12, g14, g2, g23, g3, g34, g4]))
v = [g12, g14, g23, g34]
gs = GraphSet(u).subgraphs(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g12, g14, g4]))
gs = GraphSet(u).supergraphs(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g12, g123, g1234, g134, g14]))
gs = GraphSet(u).non_subgraphs(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g123, g1234, g134]))
gs = GraphSet(u).non_supergraphs(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g4]))
gs1 = GraphSet({}) - GraphSet([g1, g34])
gs2 = gs1.including(GraphSet([g1, g2]))
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 11)
gs2 = gs1.including(g1)
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 7)
gs2 = gs1.including((2,1))
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 7)
gs2 = gs1.including(1)
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 11)
self.assertRaises(KeyError, gs1.including, (1, 4))
self.assertRaises(KeyError, gs1.including, 5)
gs2 = gs1.excluding(GraphSet([g1, g2]))
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 3)
gs2 = gs1.excluding(g1)
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 7)
gs2 = gs1.excluding(e2)
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 6)
gs2 = gs1.excluding(1)
self.assertTrue(isinstance(gs2, GraphSet))
self.assertEqual(len(gs2), 3)
self.assertRaises(KeyError, gs1.excluding, (1, 4))
self.assertRaises(KeyError, gs1.excluding, 5)
v = [g12, g14, g23, g34]
gs = GraphSet(u).included(GraphSet(v))
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g12, g14, g4]))
gs = GraphSet(u).included(g12)
self.assertTrue(isinstance(gs, GraphSet))
self.assertEqual(gs, GraphSet([g0, g1, g12]))
示例2: GraphSet
# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import including [as 别名]
GraphSet.set_universe(universe)
start,goal = 1,(dimension[0]+1)*(dimension[1]+1)
#create an empty GraphSet
paths = GraphSet()
paths_no_mp = GraphSet()
for i in range(start,goal):
print i
for j in range(i+1,goal+1):
#paths = GraphSet.union(paths,GraphSet.paths(i,j))
"""Exclude midpoint"""
if i != midpoint and j != midpoint:
paths_no_mp = GraphSet.union(paths_no_mp,GraphSet.paths(i,j))
paths = GraphSet.union(paths,GraphSet.paths(i,j))
pathsThruMidpoint = paths.including(midpoint)
pathsNoMidpoint = paths_no_mp.including(midpoint)
#tl.draw(pathsThruMidpoint.choice())
print "number of paths through midpoint: " + str(pathsThruMidpoint.len())
print "number of paths without stopping at midpoint: " + str(pathsNoMidpoint.len())
print_edge_numbering(paths.universe(),dim[0],dim[1])
#print paths.universe()
#for p in pathsThruMidpoint:
# print p
#dim = (dimension[0]+1,dimension[1]+1)
#""" AC: SAVE ZDD TO FILE
f = open("graphs/asdf-%d-%d-%d.zdd" % (dim[0],dim[1],midpoint),"w")
pathsThruMidpoint.dump(f)
f.close()