code
stringlengths
17
6.64M
class GraphQuery(GenericGraphQuery): def __init__(self, graph_db=None, query_dict=None, display_cols=None, **kwds): "\n A query for an instance of :class:`~GraphDatabase`.\n\n This class nicely wraps the :class:`sage.databases.sql_db.SQLQuery`\n class located in :mod:`sage.databases....
class GraphDatabase(SQLDatabase): def __init__(self): "\n Graph Database\n\n This class interfaces with the ``sqlite`` database ``graphs.db``. It is\n an immutable database that inherits from\n :class:`~sage.databases.sql_db.SQLDatabase` (see\n :mod:`sage.databases.sql_...
class NodeType(Enum): '\n NodeType is an enumeration class used to define the various types of nodes\n in modular decomposition tree.\n\n The various node types defined are\n\n - ``PARALLEL`` -- indicates the node is a parallel module\n\n - ``SERIES`` -- indicates the node is a series module\n\n ...
class NodeSplit(Enum): '\n Enumeration class used to specify the split that has occurred at the node or\n at any of its descendants.\n\n ``NodeSplit`` is defined for every node in modular decomposition tree and is\n required during the refinement and promotion phase of modular decomposition\n tree ...
class VertexPosition(Enum): '\n Enumeration class used to define position of a vertex w.r.t source in\n modular decomposition.\n\n For computing modular decomposition of connected graphs a source vertex is\n chosen. The position of vertex is w.r.t this source vertex. The various\n positions defined...
class Node(): '\n Node class stores information about the node type, node split and index of\n the node in the parent tree.\n\n Node type can be ``PRIME``, ``SERIES``, ``PARALLEL``, ``NORMAL`` or\n ``FOREST``. Node split can be ``NO_SPLIT``, ``LEFT_SPLIT``, ``RIGHT_SPLIT``\n or ``BOTH_SPLIT``. A no...
def create_prime_node(): '\n Return a prime node with no children\n\n OUTPUT:\n\n A node object with node_type set as NodeType.PRIME\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decomposition import create_prime_node\n sage: node = create_prime_node()\n s...
def create_parallel_node(): '\n Return a parallel node with no children\n\n OUTPUT:\n\n A node object with node_type set as NodeType.PARALLEL\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decomposition import create_parallel_node\n sage: node = create_parallel_no...
def create_series_node(): '\n Return a series node with no children\n\n OUTPUT:\n\n A node object with node_type set as NodeType.SERIES\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decomposition import create_series_node\n sage: node = create_series_node()\n ...
def create_normal_node(vertex): '\n Return a normal node with no children\n\n INPUT:\n\n - ``vertex`` -- vertex number\n\n OUTPUT:\n\n A node object representing the vertex with node_type set as NodeType.NORMAL\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decompo...
def print_md_tree(root): '\n Print the modular decomposition tree\n\n INPUT:\n\n - ``root`` -- root of the modular decomposition tree\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decomposition import *\n sage: print_md_tree(modular_decomposition(graphs.Icosahedr...
def gamma_classes(graph): '\n Partition the edges of the graph into Gamma classes.\n\n Two distinct edges are Gamma related if they share a vertex but are not\n part of a triangle. A Gamma class of edges is a collection of edges such\n that any edge in the class can be reached from any other by a cha...
def habib_maurer_algorithm(graph, g_classes=None): '\n Compute the modular decomposition by the algorithm of Habib and Maurer\n\n Compute the modular decomposition of the given graph by the algorithm of\n Habib and Maurer [HM1979]_ . If the graph is disconnected or its complement\n is disconnected ret...
def test_modular_decomposition(tree_root, graph): '\n Test the input modular decomposition tree using recursion.\n\n INPUT:\n\n - ``tree_root`` -- root of the modular decomposition tree to be tested\n\n - ``graph`` -- graph whose modular decomposition tree needs to be tested\n\n OUTPUT:\n\n ``Tr...
def test_maximal_modules(tree_root, graph): '\n Test the maximal nature of modules in a modular decomposition tree.\n\n Suppose the module `M = [M_1, M_2, \\cdots, n]` is the input modular\n decomposition tree. Algorithm forms pairs like `(M_1, M_2), (M_1, M_3),\n \\cdots, (M_1, M_n)`; `(M_2, M_3), (M...
def get_vertices(component_root): '\n Compute the list of vertices in the (co)component\n\n INPUT:\n\n - ``component_root`` -- root of the (co)component whose vertices need to be\n returned as a list\n\n OUTPUT:\n\n list of vertices in the (co)component\n\n EXAMPLES::\n\n sage: from ...
def get_module_type(graph): '\n Return the module type of the root of the modular decomposition tree of\n ``graph``.\n\n INPUT:\n\n - ``graph`` -- input sage graph\n\n OUTPUT:\n\n ``PRIME`` if graph is PRIME, ``PARALLEL`` if graph is PARALLEL and\n ``SERIES`` if graph is of type SERIES\n\n ...
def form_module(index, other_index, tree_root, graph): '\n Forms a module out of the modules in the module pair.\n\n Let `M_1` and `M_2` be the input modules. Let `V` be the set of vertices in\n these modules. Suppose `x` is a neighbor of subset of the vertices in `V`\n but not all the vertices and `x...
def test_module(module, graph): '\n Test whether input module is actually a module\n\n INPUT:\n\n - ``module`` -- module which needs to be tested\n\n - ``graph`` -- input sage graph which contains the module\n\n OUTPUT:\n\n ``True`` if input module is a module by definition else ``False``\n\n ...
def children_node_type(module, node_type): '\n Check whether the node type of the children of ``module`` is ``node_type``.\n\n INPUT:\n\n - ``module`` -- module which is tested\n\n - ``node_type`` -- input node_type\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_decompositions.modular_decom...
def either_connected_or_not_connected(v, vertices_in_module, graph): '\n Check whether ``v`` is connected or disconnected to all vertices in the\n module.\n\n INPUT:\n\n - ``v`` -- vertex tested\n\n - ``vertices_in_module`` -- list containing vertices in the module\n\n - ``graph`` -- graph to wh...
def tree_to_nested_tuple(root): '\n Convert a modular decomposition tree to a nested tuple.\n\n INPUT:\n\n - ``root`` -- the root of the modular decomposition tree\n\n OUTPUT:\n\n A tuple whose first element is the type of the root of the tree and whose\n subsequent nodes are either vertex label...
def nested_tuple_to_tree(nest): '\n Turn a tuple representing the modular decomposition into a tree.\n\n INPUT:\n\n - ``nest`` -- a nested tuple of the form returned by\n :meth:`tree_to_nested_tuple`\n\n OUTPUT:\n\n The root node of a modular decomposition tree.\n\n EXAMPLES::\n\n sa...
def equivalent_trees(root1, root2): '\n Check that two modular decomposition trees are the same.\n\n Verify that the structure of the trees is the same. Two leaves are\n equivalent if they represent the same vertex, two internal nodes are\n equivalent if they have the same nodes type and the same numb...
def relabel_tree(root, perm): '\n Relabel the leaves of a tree according to a dictionary\n\n INPUT:\n\n - ``root`` -- the root of the tree\n\n - ``perm`` -- a function, dictionary, list, permutation, or ``None``\n representing the relabeling. See\n :meth:`~sage.graphs.generic_graph.GenericGr...
@random_testing def test_gamma_modules(trials, vertices, prob, verbose=False): '\n Verify that the vertices of each gamma class of a random graph are modules\n of that graph.\n\n INPUT:\n\n - ``trials`` -- the number of trials to run\n\n - ``vertices`` -- the size of the graph to use\n\n - ``pro...
@random_testing def permute_decomposition(trials, algorithm, vertices, prob, verbose=False): '\n Check that a graph and its permuted relabeling have the same modular\n decomposition.\n\n We generate a ``trials`` random graphs and then generate an isomorphic graph\n by relabeling the original graph. We...
def random_md_tree(max_depth, max_fan_out, leaf_probability): '\n Create a random MD tree.\n\n INPUT:\n\n - ``max_depth`` -- the maximum depth of the tree.\n\n - ``max_fan_out`` -- the maximum number of children a node can have\n (must be >=4 as a prime node must have at least 4 vertices).\n\n ...
def md_tree_to_graph(root): '\n Create a graph having the given MD tree.\n\n For the prime nodes we use that every path of length 4 or more is prime.\n\n TODO: accept a function that generates prime graphs as a parameter and\n use that in the prime nodes.\n\n EXAMPLES::\n\n sage: from sage.g...
@random_testing def recreate_decomposition(trials, algorithm, max_depth, max_fan_out, leaf_probability, verbose=False): '\n Verify that we can recreate a random MD tree.\n\n We create a random MD tree, then create a graph having that decomposition,\n then find a modular decomposition for that graph, and ...
def graph_editor(graph=None, **display_options): "\n Return a graph editor widget.\n\n The graph editor widget can be displayed with Jupyter or JupyterLab.\n It is provided by the ``phitigra`` optional package, see\n https://github.com/jfraymond/phitigra for details about the\n possible options (ch...
def __append_to_doc(methods): global __doc__ __doc__ += '\n.. csv-table::\n :class: contentstable\n :widths: 33, 33, 33\n :delim: |\n\n' h = ((len(methods) + 2) // 3) reordered_methods = (([0] * 3) * h) for (i, m) in enumerate(methods): reordered_methods[((3 * (i % h)) + (i // h))...
class GraphGenerators(): '\n A class consisting of constructors for several common graphs, as well as\n orderly generation of isomorphism class representatives. See the\n :mod:`module\'s help <sage.graphs.graph_generators>` for a list of supported\n constructors.\n\n A list of all graphs and graph ...
def canaug_traverse_vert(g, aut_gens, max_verts, property, dig=False, loops=False, sparse=True): "\n Main function for exhaustive generation. Recursive traversal of a\n canonically generated tree of isomorph free (di)graphs satisfying a\n given property.\n\n INPUT:\n\n\n - ``g`` - current position...
def check_aut(aut_gens, cut_vert, n): '\n Helper function for exhaustive generation.\n\n At the start, check_aut is given a set of generators for the\n automorphism group, aut_gens. We already know we are looking for\n an element of the auto- morphism group that sends cut_vert to n,\n and check_aut...
def canaug_traverse_edge(g, aut_gens, property, dig=False, loops=False, sparse=True): '\n Main function for exhaustive generation. Recursive traversal of a\n canonically generated tree of isomorph free graphs satisfying a\n given property.\n\n INPUT:\n\n\n - ``g`` - current position on the tree.\n...
def check_aut_edge(aut_gens, cut_edge, i, j, n, dig=False): '\n Helper function for exhaustive generation.\n\n At the start, check_aut_edge is given a set of generators for the\n automorphism group, aut_gens. We already know we are looking for\n an element of the auto- morphism group that sends cut_ed...
def from_graph6(G, g6_string): "\n Fill ``G`` with the data of a graph6 string.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``g6_string`` -- a graph6 string\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_input import from_graph6\n sage: g = Graph()\n sage: from_graph6(g, 'IheA@GUA...
def from_sparse6(G, g6_string): "\n Fill ``G`` with the data of a sparse6 string.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``g6_string`` -- a sparse6 string\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_input import from_sparse6\n sage: g = Graph()\n sage: from_sparse6(g, ':I`...
def from_dig6(G, dig6_string): '\n Fill ``G`` with the data of a dig6 string.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``dig6_string`` -- a dig6 string\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_input import from_dig6\n sage: g = DiGraph()\n sage: from_dig6(g, digraphs.Circ...
def from_seidel_adjacency_matrix(G, M): '\n Fill ``G`` with the data of a Seidel adjacency matrix.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``M`` -- a Seidel adjacency matrix\n\n EXAMPLES::\n\n sage: from sage.graphs.graph_input import from_seidel_adjacency_matrix\n sage: g = Graph()\n...
def from_adjacency_matrix(G, M, loops=False, multiedges=False, weighted=False): '\n Fill ``G`` with the data of an adjacency matrix.\n\n INPUT:\n\n - ``G`` -- a :class:`Graph` or :class:`DiGraph`\n\n - ``M`` -- an adjacency matrix\n\n - ``loops``, ``multiedges``, ``weighted`` -- booleans (default: ...
def from_incidence_matrix(G, M, loops=False, multiedges=False, weighted=False): '\n Fill ``G`` with the data of an incidence matrix.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``M`` -- an incidence matrix\n\n - ``loops``, ``multiedges``, ``weighted`` -- booleans (default: ``False``);\n whether to...
def from_oriented_incidence_matrix(G, M, loops=False, multiedges=False, weighted=False): "\n Fill ``G`` with the data of an *oriented* incidence matrix.\n\n An oriented incidence matrix is the incidence matrix of a directed graph, in\n which each non-loop edge corresponds to a `+1` and a `-1`, indicating...
def from_dict_of_dicts(G, M, loops=False, multiedges=False, weighted=False, convert_empty_dict_labels_to_None=False): '\n Fill ``G`` with the data of a dictionary of dictionaries.\n\n INPUT:\n\n - ``G`` -- a graph\n\n - ``M`` -- a dictionary of dictionaries\n\n - ``loops``, ``multiedges``, ``weight...
def from_dict_of_lists(G, D, loops=False, multiedges=False, weighted=False): '\n Fill ``G`` with the data of a dictionary of lists.\n\n INPUT:\n\n - ``G`` -- a :class:`Graph` or :class:`DiGraph`\n\n - ``D`` -- a dictionary of lists\n\n - ``loops``, ``multiedges``, ``weighted`` -- booleans (default:...
def from_networkx_graph(G, gnx, weighted=None, loops=None, multiedges=None, convert_empty_dict_labels_to_None=None): '\n Fill `G` with the data of a NetworkX (di)graph.\n\n INPUT:\n\n - ``G`` -- a :class:`Graph` or :class:`DiGraph`\n\n - ``gnx`` -- a NetworkX ``Graph``, ``MultiGraph``, ``DiGraph`` or\...
def check_tkz_graph(): "\n Check if the proper LaTeX packages for the ``tikzpicture`` environment are\n installed in the user's environment, and issue a warning otherwise.\n\n The warning is only issued on the first call to this function. So any\n doctest that illustrates the use of the tkz-graph pack...
def have_tkz_graph(): "\n Return ``True`` if the proper LaTeX packages for the ``tikzpicture``\n environment are installed in the user's environment, namely ``tikz``,\n ``tkz-graph`` and ``tkz-berge``.\n\n The result is cached.\n\n See also :meth:`sage.misc.latex.Latex.has_file`\n\n TESTS::\n\n ...
@cached_function def setup_latex_preamble(): '\n Add appropriate ``\\usepackage{...}``, and other instructions to the latex\n preamble for the packages that are needed for processing graphs(``tikz``,\n ``tkz-graph``, ``tkz-berge``), if available in the ``LaTeX`` installation.\n\n See also :meth:`sage....
class GraphLatex(SageObject): '\n A class to hold, manipulate and employ options for converting\n a graph to LaTeX.\n\n This class serves two purposes. First it holds the values of various\n options designed to work with the ``tkz-graph`` LaTeX package for rendering\n graphs. As such, a graph tha...
def from_whatever(data): "\n Return a list of Sage Graphs, given a list of whatever kind of data.\n\n INPUT:\n\n - ``data`` -- can be a string, a list/iterable of strings, or a readable\n file-like object\n\n EXAMPLES::\n\n sage: l = ['N@@?N@UGAGG?gGlKCMO', ':P_`cBaC_ACd`C_@BC`ABDHaEH_@BF_...
def _from_whatever(data, fmt=None): "\n Implementation details of :func:`from_whatever`.\n\n INPUT:\n\n - ``data`` -- can be a string, a list/iterable of strings, or a readable\n file-like object\n\n - ``fmt`` -- string (default: ``None``); format of ``data``. It can be\n either ``'graph6'``...
def from_graph6(data): "\n Return a list of Sage Graphs, given a list of graph6 data.\n\n INPUT:\n\n - ``data`` -- can be a string, a list of strings, or a file stream\n\n EXAMPLES::\n\n sage: l = ['N@@?N@UGAGG?gGlKCMO', 'XsGGWOW?CC?C@HQKHqOjYKC_uHWGX?P?~TqIKA`OA@SAOEcEA??']\n sage: grap...
def from_sparse6(data): "\n Return a list of Sage Graphs, given a list of sparse6 data.\n\n INPUT:\n\n - ``data`` -- can be a string, a list of strings, or a file stream\n\n EXAMPLES::\n\n sage: g1 = ':P_`cBaC_ACd`C_@BC`ABDHaEH_@BF_@CHIK_@BCEHKL_BIKM_BFGHI'\n sage: g2 = ':f`??KO?B_OOSCGE...
def to_graph6(graphs, file=None, output_list=False): "\n Convert a list of Sage graphs to a single string of graph6 graphs.\n\n If ``file`` is specified, then the string will be written quietly to the\n file. If ``output_list`` is ``True``, then a list of strings will be\n returned, one string per gr...
def to_sparse6(graphs, file=None, output_list=False): "\n Convert a list of Sage graphs to a single string of sparse6 graphs.\n\n If ``file`` is specified, then the string will be written quietly to the\n file. If ``output_list`` is ``True``, then a list of strings will be\n returned, one string per ...
def _to_graph6(graphs, file=None, output_list=False, sparse=False): "\n Internal implementation of :func:`to_graph6` and :func:`to_sparse6`.\n\n EXAMPLES::\n\n sage: l = [graphs.DodecahedralGraph(), graphs.PetersenGraph()]\n sage: graphs_list._to_graph6(l, sparse=False)\n 'ShCHGD@?K?_@?...
def to_graphics_array(graph_list, **kwds): "\n Draw all graphs in a graphics array\n\n INPUT:\n\n - ``graph_list`` -- a Python list of Sage Graphs\n\n GRAPH PLOTTING:\n\n Defaults to circular layout for graphs. This allows for a nicer display in a\n small area and takes much less time to compute...
def show_graphs(graph_list, **kwds): "\n Show a maximum of 20 graphs from ``graph_list`` in a sage graphics array.\n\n If more than 20 graphs are given in the list argument, then it will display\n one graphics array after another with each containing at most 20 graphs.\n\n Note that to save the image ...
class GraphPlot(SageObject): def __init__(self, graph, options): "\n Return a ``GraphPlot`` object, which stores all the parameters needed\n for plotting (Di)Graphs.\n\n A ``GraphPlot`` has a plot and show function, as well as some functions\n to set parameters for vertices an...
def gen_html_code(G, vertex_labels=True, edge_labels=False, vertex_partition=[], vertex_colors=None, edge_partition=[], force_spring_layout=False, charge=(- 120), link_distance=30, link_strength=2, gravity=0.04, vertex_size=7, edge_thickness=4): '\n Create a .html file showing the graph using `d3.js <https://d...
class HypergraphGenerators(): '\n A class consisting of constructors for common hypergraphs.\n ' def nauty(self, number_of_sets, number_of_vertices, multiple_sets=False, vertex_min_degree=None, vertex_max_degree=None, set_max_size=None, set_min_size=None, regular=False, uniform=False, max_intersection=...
class GraphClass(SageObject, CachedRepresentation): '\n An instance of this class represents a Graph Class, matching some entry in\n the ISGCI database.\n\n EXAMPLES:\n\n Testing the inclusion of two classes::\n\n sage: Chordal = graph_classes.Chordal\n sage: Trees = graph_classes.Tree\n...
class GraphClasses(UniqueRepresentation): def get_class(self, id): '\n Return the class corresponding to the given id in the ISGCI database.\n\n INPUT:\n\n - ``id`` (string) -- the desired class\' ID\n\n .. SEEALSO::\n\n :meth:`~sage.graphs.isgci.GraphClasses.show_a...
def _XML_to_dict(root): '\n Return the XML data as a dictionary.\n\n INPUT:\n\n - ``root`` -- an ``xml.etree.cElementTree.ElementTree`` object.\n\n OUTPUT:\n\n A dictionary representing the XML data.\n\n EXAMPLES::\n\n sage: graph_classes.Perfect.description() # indirect doctest\n ...
def lovasz_theta(graph): '\n Return the value of Lovász theta-function of graph.\n\n For a graph `G` this function is denoted by `\\theta(G)`, and it can be\n computed in polynomial time. Mathematically, its most important property is\n the following:\n\n .. MATH::\n\n \\alpha(G)\\leq\\theta...
def strong_orientations_iterator(G): "\n Return an iterator over all strong orientations of a graph `G`.\n\n A strong orientation of a graph is an orientation of its edges such that the\n obtained digraph is strongly connected (i.e. there exist a directed path\n between each pair of vertices). Accordi...
def _strong_orientations_of_a_mixed_graph(Dg, V, E): '\n Helper function for the generation of all strong orientations.\n\n Generates all strong orientations of a given partially directed graph\n (also called mixed graph). The algorithm finds bound edges i.e undirected\n edges whose orientation is for...
def random_orientation(G): '\n Return a random orientation of a graph `G`.\n\n An *orientation* of an undirected graph is a directed graph such that every\n edge is assigned a direction. Hence there are `2^m` oriented digraphs for a\n simple graph with `m` edges.\n\n INPUT:\n\n - ``G`` -- a Grap...
def breadth_first_level_search(G, start): "\n Generate a sequence of dictionaries, each mapping the vertices at\n distance ``i`` from ``start`` to the set of their neighbours at\n distance ``i+1``.\n\n Originally written by D. Eppstein for the PADS library\n (http://www.ics.uci.edu/~eppstein/PADS/)...
def depth_first_traversal(G, start): "\n Generate a sequence of triples (v,w,edgetype) for DFS of graph G.\n\n Originally written by D. Eppstein for the PADS library\n (http://www.ics.uci.edu/~eppstein/PADS/).\n\n INPUT:\n\n - ``G`` -- a graph to perform the search on.\n\n - ``start`` -- vertex ...
def is_partial_cube(G, certificate=False): "\n Test whether the given graph is a partial cube.\n\n A partial cube is a graph that can be isometrically embedded into a\n hypercube, i.e., its vertices can be labelled with (0,1)-vectors of some\n fixed length such that the distance between any two vertic...
def _set_contiguous(tree, x): "\n Helper function for updating ``tree``.\n\n The objective is to ensure that the sets containing ``x`` are contiguous for\n any admissible permutation of its subtrees.\n\n TESTS::\n\n sage: from sage.graphs.pq_trees import _set_contiguous, P\n sage: p1 = P...
def _new_P(liste): "\n Helper function returning a new P-tree.\n\n TESTS::\n\n sage: from sage.graphs.pq_trees import _new_P\n sage: _new_P([[1,2], [2,3]])\n ('P', [{1, 2}, {2, 3}])\n sage: _new_P([[1,2]])\n [1, 2]\n " if (len(liste) > 1): return P(liste) ...
def _new_Q(liste): "\n Helper function returning a new Q-tree.\n\n TESTS::\n\n sage: from sage.graphs.pq_trees import _new_Q\n sage: _new_Q([[1,2], [2,3]])\n ('Q', [{1, 2}, {2, 3}])\n sage: _new_Q([[1,2]])\n [1, 2]\n " if (len(liste) > 1): return Q(liste) ...
def _flatten(x): "\n Helper function returning a flatten version of ``x``, if ``x`` is a PQ-tree.\n\n TESTS::\n\n sage: from sage.graphs.pq_trees import P, Q, _flatten\n sage: p = Q([P([[1,2], [2,3]])])\n sage: _flatten(p)\n ('P', [{1, 2}, {2, 3}])\n sage: _flatten([p, p])...
def reorder_sets(sets): '\n Reorders a collection of sets such that each element appears on an\n interval.\n\n Given a collection of sets `C = S_1,...,S_k` on a ground set `X`,\n this function attempts to reorder them in such a way that `\\forall\n x \\in X` and `i<j` with `x\\in S_i, S_j`, then `x...
class PQ(): '\n PQ-Trees\n\n This class should not be instantiated by itself: it is extended by\n :class:`P` and :class:`Q`. See the documentation of\n :mod:`sage.graphs.pq_trees` for more information.\n\n AUTHOR : Nathann Cohen\n ' def __init__(self, seq): "\n Construction o...
class P(PQ): '\n A P-Tree is a PQ-Tree whose children can be permuted in any way.\n\n For more information, see the documentation of :mod:`sage.graphs.pq_trees`.\n ' def set_contiguous(self, v): "\n Updates ``self`` so that the sets containing ``v`` are\n contiguous for any adm...
class Q(PQ): '\n A Q-Tree is a PQ-Tree whose children are ordered up to reversal\n\n For more information, see the documentation of :mod:`sage.graphs.pq_trees`.\n ' def set_contiguous(self, v): "\n Updates ``self`` so that the sets containing ``v`` are\n contiguous for any admi...
def print_header_ps(s): "\n Give the header for a postscript file.\n\n EXAMPLES::\n\n sage: from sage.graphs.print_graphs import print_header_ps\n sage: print(print_header_ps(''))\n %% --- Auto-generated PostScript ---\n %% Generated on:\n %%...\n " s += '%% --- Aut...
def print_header_eps(s, xmin, ymin, xmax, ymax): "\n Give the header for an encapsulated postscript file.\n\n EXAMPLES::\n\n sage: from sage.graphs.print_graphs import print_header_eps\n sage: print(print_header_eps('',0,0,1,1))\n %!PS-Adobe-3.0 EPSF-3.0\n %%BoundingBox: 0 0 1 1\...
def print_functions(s): "\n Define edge and point drawing functions.\n\n EXAMPLES::\n\n sage: from sage.graphs.print_graphs import print_functions\n sage: print(print_functions(''))\n /point %% input: x y\n { moveto\n gsave\n currentpoint translate\n 0 ...
def print_graph_ps(vert_ls, edge_iter, pos_dict): '\n Give postscript text for drawing a graph.\n\n EXAMPLES::\n\n sage: from sage.graphs.print_graphs import print_graph_ps\n sage: P = graphs.PetersenGraph()\n sage: print(print_graph_ps(P.vertices(sort=True), P.edges(sort=True), sage.gr...
def print_graph_eps(vert_ls, edge_iter, pos_dict): '\n Give postscript text for drawing a graph.\n\n EXAMPLES::\n\n sage: from sage.graphs.print_graphs import print_graph_eps\n sage: P = graphs.PetersenGraph()\n sage: print(print_graph_eps(P.vertices(sort=True), P.edges(sort=True), sage...
def _triangulate(g, comb_emb): "\n Helper function to schnyder method for computing coordinates in the plane to\n plot a planar graph with no edge crossings.\n\n Given a connected graph g with at least 3 vertices and a planar combinatorial\n embedding comb_emb of g, modify g in place to form a graph w...
def _normal_label(g, comb_emb, external_face): '\n Helper function to schnyder method for computing coordinates in\n the plane to plot a planar graph with no edge crossings.\n\n Constructs a normal labelling of a triangular graph g, given the\n planar combinatorial embedding of g and a designated exte...
def _realizer(g, x, example=False): '\n Given a triangulated graph g and a normal labeling constructs the\n realizer and returns a dictionary of three trees determined by the\n realizer, each spanning all interior vertices and rooted at one of\n the three external vertices.\n\n A realizer is a dire...
def _compute_coordinates(g, x): '\n Given a triangulated graph g with a dict of trees given by the\n realizer and tuple of the external vertices, we compute the\n coordinates of a planar geometric embedding in the grid.\n\n The coordinates will be set to the ``_pos`` attribute of g.\n\n INPUT:\n\n ...
class TreeNode(): '\n A class to represent each node in the trees used by ``_realizer`` and\n ``_compute_coordinates`` when finding a planar geometric embedding in\n the grid.\n\n Each tree node is doubly linked to its parent and children.\n\n INPUT:\n\n - ``parent`` -- the parent TreeNode of ``...
def minimal_schnyder_wood(graph, root_edge=None, minimal=True, check=True): "\n Return the minimal Schnyder wood of a planar rooted triangulation.\n\n INPUT:\n\n - graph -- a planar triangulation, given by a graph with an embedding.\n\n - root_edge -- a pair of vertices (default is from ``-1`` to ``-2...
@contextmanager def removed_multiedge(G, unlabeled_edge): "\n A context manager which removes an edge with multiplicity from the\n graph `G` and restores it upon exiting.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import removed_multiedge\n sage: G = Graph(multiedges=True)\n...
@contextmanager def removed_edge(G, edge): '\n A context manager which removes an edge from the graph `G` and\n restores it upon exiting.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import removed_edge\n sage: G = Graph()\n sage: G.add_edge(0,1)\n sage: G.edges(...
@contextmanager def contracted_edge(G, unlabeled_edge): "\n Delete the first vertex in the edge, and make all the edges that\n went from it go to the second vertex.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import contracted_edge\n sage: G = Graph(multiedges=True)\n ...
@contextmanager def removed_loops(G): "\n A context manager which removes all the loops in the graph `G`.\n It yields a list of the loops, and restores the loops upon\n exiting.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import removed_loops\n sage: G = Graph(multiedges=T...
def underlying_graph(G): "\n Given a graph `G` with multi-edges, returns a graph where all the\n multi-edges are replaced with a single edge.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import underlying_graph\n sage: G = Graph(multiedges=True)\n sage: G.add_edges([(0,...
def edge_multiplicities(G): '\n Return the dictionary of multiplicities of the edges in the\n graph `G`.\n\n EXAMPLES::\n\n sage: from sage.graphs.tutte_polynomial import edge_multiplicities\n sage: G = Graph({1: [2,2,3], 2: [2], 3: [4,4], 4: [2,2,2]})\n sage: sorted(edge_multiplicit...
class Ear(): '\n An ear is a sequence of vertices\n\n Here is the definition from [HPR2010]_:\n\n An ear in a graph is a path `v_1 - v_2 - \\dots - v_n - v_{n+1}`\n where `d(v_1) > 2`, `d(v_{n+1}) > 2` and\n `d(v_2) = d(v_3) = \\dots = d(v_n) = 2`.\n\n A cycle is viewed as a special ear where `v...
class EdgeSelection(): pass