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


Python SimpleGraphHelper.obtain_graph方法代码示例

本文整理汇总了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)
开发者ID:MassimoLauria,项目名称:cnfgen,代码行数:11,代码来源:graphisomorphism.py

示例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)
开发者ID:jakobnordstrom,项目名称:cnfgen,代码行数:32,代码来源:tseitin.py

示例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))
开发者ID:marcvinyals,项目名称:cnfgen,代码行数:10,代码来源:coloring.py

示例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 )
开发者ID:MassimoLauria,项目名称:cnfgen,代码行数:10,代码来源:dominatingset.py

示例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)
开发者ID:MassimoLauria,项目名称:cnfgen,代码行数:10,代码来源:ordering.py

示例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)
开发者ID:chansonyhu,项目名称:cnfgen,代码行数:10,代码来源:subgraph.py

示例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)
开发者ID:marcvinyals,项目名称:cnfgen,代码行数:12,代码来源:dominatingsetopb.py

示例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)
开发者ID:marcvinyals,项目名称:cnfgen,代码行数:13,代码来源:vertexcover.py

示例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)
开发者ID:marcvinyals,项目名称:cnfgen,代码行数:5,代码来源:counting.py


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