cnfgen.clitools.graph_args module

Graph arguments on the command line

Whenever the argument of a command line is a graph <G>, this graph should be specified using one from a number of choices. For example

: gnp 10 .5 : gnm 10 40 addedges 4 : grid 4 3 5 plantclique 5

Since a graph specification is very commonly an argument in our formulas, we need a functionality that can be reused.

The first element in a graph argument must either be - a graph distribution/construction, followed by its arguments; or - a filename which implies the graph format; or - a graph format followed by filename.

Other options may follow:

The option plantedclique (followed by a positive integer) implies that a random clique of given size must be added to the graph. It applies only to simple graphs.

The option plantedclique (followed by two positive integers) implies that a random biclique of given size must be added to the graph. It applies only to bipartite graphs.

The option addedges (followed by a non negative integer) adds to the graph a the specified number of edges, chosen at random among the missing ones.

The option save indicates that the graph generated must be saved into a file. save must be followed either by - a filename which implies the graph format; or - a graph format followed by filename.

Copyright (C) 2020, 2021 Massimo Lauria <massimo.lauria@uniroma1.it> https://github.com/MassimoLauria/cnfgen.git

class ObtainBipartiteGraph(option_strings, dest, nargs=None, **kwargs)

Bases: cnfgen.clitools.graph_args.ObtainGraphAction

Methods

__call__(parser, args, values[, option_string]) Call self as a function.
class ObtainDirectedAcyclicGraph(option_strings, dest, nargs=None, **kwargs)

Bases: cnfgen.clitools.graph_args.ObtainGraphAction

Methods

__call__(parser, args, values[, option_string]) Call self as a function.
class ObtainGraphAction(option_strings, dest, nargs=None, **kwargs)

Bases: argparse.Action

Methods

__call__(parser, namespace, values[, …]) Call self as a function.
class ObtainSimpleGraph(option_strings, dest, nargs=None, **kwargs)

Bases: cnfgen.clitools.graph_args.ObtainGraphAction

Methods

__call__(parser, args, values[, option_string]) Call self as a function.
construction_for_another_type(cname, graphtype)

Check if the construction name is valid for other types of graph

determine_graph_format_from_filename(filename)
format_for_another_type(fname, graphtype)
make_graph_from_spec(graphtype, args)

Produce a graph from a graph specification string

obtain_graph(parsed)

Build a graph according to parsed graph argument

parse_graph_argument(graphtype, spec)

Parse the command line part that corresponds to a graph argument

Here we assume that all parts have numeric arguments, except for ‘save’