本文整理汇总了Python中cnfformula.cmdline.SimpleGraphHelper.obtain_graph方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleGraphHelper.obtain_graph方法的具体用法?Python SimpleGraphHelper.obtain_graph怎么用?Python SimpleGraphHelper.obtain_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cnfformula.cmdline.SimpleGraphHelper
的用法示例。
在下文中一共展示了SimpleGraphHelper.obtain_graph方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build a graph automorphism formula according to the arguments
Arguments:
- `args`: command line options
"""
G1 = SimpleGraphHelper.obtain_graph(args,suffix="1")
G2 = SimpleGraphHelper.obtain_graph(args,suffix="2")
return GraphIsomorphism(G1,G2)
示例2: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build Tseitin formula according to the arguments
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
if G.order()<1:
charge=None
elif args.charge=='first':
charge=[1]+[0]*(G.order()-1)
else: # random vector
charge=[random.randint(0,1) for _ in xrange(G.order()-1)]
parity=sum(charge) % 2
if args.charge=='random':
charge.append(random.randint(0,1))
elif args.charge=='randomodd':
charge.append(1-parity)
elif args.charge=='randomeven':
charge.append(parity)
else:
raise ValueError('Illegal charge specification on command line')
return TseitinFormula(G,charge)
示例3: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build a k-colorability formula according to the arguments
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
return GraphColoringFormula(G,range(1,args.k+1))
示例4: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build the k-dominating set formula
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
return DominatingSet(G, args.d, alternative = args.alternative )
示例5: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build a Graph ordering principle formula according to the arguments
Arguments:
- `args`: command line options
"""
G= SimpleGraphHelper.obtain_graph(args)
return GraphOrderingPrinciple(G,args.total,args.smart,args.plant,args.knuth)
示例6: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build a k-clique formula according to the arguments
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
return CliqueFormula(G,args.k)
示例7: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build the k-dominating set formula
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
D = args.d
if args.regular : D = G.order()/(2*G.number_of_edges()/G.order()+1)
return DominatingSetOPB(G, D, args.tiling, args.seed)
示例8: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
"""Build the k-dominating set formula
Arguments:
- `args`: command line options
"""
G = SimpleGraphHelper.obtain_graph(args)
D = args.d
if args.rational : D = G.order()/2
elif args.no_rational : D = G.order()/2-1
return VertexCover(G, D)
示例9: build_cnf
# 需要导入模块: from cnfformula.cmdline import SimpleGraphHelper [as 别名]
# 或者: from cnfformula.cmdline.SimpleGraphHelper import obtain_graph [as 别名]
def build_cnf(args):
G = SimpleGraphHelper.obtain_graph(args)
return PerfectMatchingPrinciple(G)