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


Python GraphSet.dumps方法代码示例

本文整理汇总了Python中graphillion.GraphSet.dumps方法的典型用法代码示例。如果您正苦于以下问题:Python GraphSet.dumps方法的具体用法?Python GraphSet.dumps怎么用?Python GraphSet.dumps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphillion.GraphSet的用法示例。


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

示例1: test_io

# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import dumps [as 别名]
    def test_io(self):
        gs = GraphSet()
        st = gs.dumps()
        self.assertEqual(st, "B\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet())

        gs = GraphSet([g0])
        st = gs.dumps()
        self.assertEqual(st, "T\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet([g0]))

        v = [g0, g1, g12, g123, g1234, g134, g14, g4]
        gs = GraphSet(v)
        st = gs.dumps()
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet(v))

        # skip this test, becasue string is treated as an element
#        gs = GraphSet(st)
#        self.assertEqual(gs, GraphSet(v))

        with tempfile.TemporaryFile() as f:
            gs.dump(f)
            f.seek(0)
            gs = GraphSet.load(f)
            self.assertEqual(gs, GraphSet(v))
开发者ID:takemaru,项目名称:graphillion,代码行数:30,代码来源:graphset.py

示例2: GraphSet

# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import dumps [as 别名]
GraphSet.set_universe(universe)

ng = 20

g_univ = GraphSet({})

g1 = []
i = 1
for sg in g_univ.rand_iter():
  g1.append(sg)
  if i == ng: break
  i += 1

G1 = GraphSet(g1)
print(G1.dumps())

data = map (lambda x:x.split(" "),G1.dumps().strip().split("\n"))
data.pop()


data_fl = list(chain.from_iterable(data))

len_data_fl = len(data_fl)
num_v = len_data_fl/4

v_id = data_fl[::4]
v_lab = data_fl[1::4]
v_lo = data_fl[2::4]
v_hi = data_fl[3::4]
开发者ID:statgenetJimu,项目名称:ZDDandDiscreteDataStructure,代码行数:31,代码来源:hapSG.py

示例3: range

# 需要导入模块: from graphillion import GraphSet [as 别名]
# 或者: from graphillion.GraphSet import dumps [as 别名]
universe = []
for i in range(marker):
    universe.append((i, i + 1))

GraphSet.set_universe(universe)

g1 = []
i = 1
for i in range(n):
    tmp = []
    for j in range(marker):
        if haps[i][j] == 1:
            tmp.append(universe[j])
    if i == 0:
        g1 == [tmp]
    else:
        g1.append(tmp)

G1 = GraphSet(g1)
print "haps"
print haps
print "\nuniverse"
print universe
print "\ng1"
print g1
print "\nG1"
print G1
print "\nG1.dumps()"
print G1.dumps()
开发者ID:statgenetJimu,项目名称:ZDDandDiscreteDataStructure,代码行数:31,代码来源:p02_2.py


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