code stringlengths 17 6.64M |
|---|
def DegreeSequence(deg_sequence):
'\n Return a graph with the given degree sequence.\n\n This method raises a NetworkX error if the proposed degree sequence cannot\n be that of a graph.\n\n Graph returned is the one returned by the Havel-Hakimi algorithm, which\n constructs a simple graph by connec... |
def DegreeSequenceBipartite(s1, s2):
'\n Return a bipartite graph whose two sets have the given degree sequences.\n\n Given two different sequences of degrees `s_1` and `s_2`, this functions\n returns ( if possible ) a bipartite graph on sets `A` and `B` such that the\n vertices in `A` have `s_1` as t... |
def DegreeSequenceConfigurationModel(deg_sequence, seed=None):
'\n Return a random pseudograph with the given degree sequence.\n\n This method raises a NetworkX error if the proposed degree sequence cannot\n be that of a graph with multiple edges and loops.\n\n One requirement is that the sum of the d... |
def DegreeSequenceTree(deg_sequence):
'\n Return a tree with the given degree sequence.\n\n This method raises a NetworkX error if the proposed degree sequence cannot\n be that of a tree.\n\n Since every tree has one more vertex than edge, the degree sequence\n must satisfy ``len(deg_sequence) - su... |
def DegreeSequenceExpected(deg_sequence, seed=None):
'\n Return a random graph with expected given degree sequence.\n\n This method raises a NetworkX error if the proposed degree sequence cannot\n be that of a graph.\n\n One requirement is that the sum of the degrees must be even, since every\n edg... |
def JohnsonGraph(n, k):
'\n Returns the Johnson graph with parameters `n, k`.\n\n Johnson graphs are a special class of undirected graphs defined from systems\n of sets. The vertices of the Johnson graph `J(n,k)` are the `k`-element\n subsets of an `n`-element set; two vertices are adjacent when they ... |
def KneserGraph(n, k):
'\n Returns the Kneser Graph with parameters `n, k`.\n\n The Kneser Graph with parameters `n,k` is the graph\n whose vertices are the `k`-subsets of `[0,1,\\dots,n-1]`, and such\n that two vertices are adjacent if their corresponding sets\n are disjoint.\n\n For example, t... |
def FurerGadget(k, prefix=None):
"\n Return a Furer gadget of order ``k`` and their coloring.\n\n Construct the Furer gadget described in [CFI1992]_,\n a graph composed by a middle layer of `2^(k-1)` nodes\n and two sets of nodes `(a_0, ... , a_{k-1})` and\n `(b_0, ... , b_{k-1})`.\n Each node i... |
def CaiFurerImmermanGraph(G, twisted=False):
'\n Return the a Cai-Furer-Immerman graph from `G`, possibly a twisted\n one, and a partition of its nodes.\n\n A Cai-Furer-Immerman graph from/on `G` is a graph created by\n applying the transformation described in [CFI1992]_ on a graph\n `G`, that is s... |
def EgawaGraph(p, s):
'\n Return the Egawa graph with parameters `p`, `s`.\n\n Egawa graphs are a peculiar family of graphs devised by Yoshimi\n Egawa in [Ega1981]_ .\n The Shrikhande graph is a special case of this family of graphs,\n with parameters `(1,0)`.\n All the graphs in this family ar... |
def HammingGraph(n, q, X=None):
"\n Returns the Hamming graph with parameters ``n``, ``q`` over ``X``.\n\n Hamming graphs are graphs over the cartesian product of n copies\n of ``X``, where `q = |X|`, where the vertices, labelled with the\n corresponding tuple in `X^n`, are connected if the Hamming di... |
def BalancedTree(r, h):
'\n Returns the perfectly balanced tree of height `h \\geq 1`,\n whose root has degree `r \\geq 2`.\n\n The number of vertices of this graph is\n `1 + r + r^2 + \\cdots + r^h`, that is,\n `\\frac{r^{h+1} - 1}{r - 1}`. The number of edges is one\n less than the number of v... |
def BarbellGraph(n1, n2):
'\n Returns a barbell graph with ``2*n1 + n2`` nodes. The argument ``n1``\n must be greater than or equal to 2.\n\n A barbell graph is a basic structure that consists of a path graph\n of order ``n2`` connecting two complete graphs of order ``n1`` each.\n\n INPUT:\n\n -... |
def LollipopGraph(n1, n2):
'\n Returns a lollipop graph with n1+n2 nodes.\n\n A lollipop graph is a path graph (order n2) connected to a complete\n graph (order n1). (A barbell graph minus one of the bells).\n\n PLOTTING: Upon construction, the position dictionary is filled to\n override the spring... |
def TadpoleGraph(n1, n2):
'\n Return a tadpole graph with n1+n2 nodes.\n\n A tadpole graph is a path graph (order n2) connected to a cycle graph\n (order n1).\n\n PLOTTING: Upon construction, the position dictionary is filled to override\n the spring-layout algorithm. By convention, the cycle graph... |
def AztecDiamondGraph(n):
'\n Return the Aztec Diamond graph of order ``n``.\n\n See the :wikipedia:`Aztec_diamond` for more information.\n\n EXAMPLES::\n\n sage: graphs.AztecDiamondGraph(2)\n Aztec Diamond graph of order 2\n\n sage: [graphs.AztecDiamondGraph(i).num_verts() for i in ... |
def DipoleGraph(n):
'\n Returns a dipole graph with n edges.\n\n A dipole graph is a multigraph consisting of 2 vertices connected with n\n parallel edges.\n\n EXAMPLES:\n\n Construct and show a dipole graph with 13 edges::\n\n sage: g = graphs.DipoleGraph(13); g\n Dipole graph: Multi... |
def BubbleSortGraph(n):
'\n Returns the bubble sort graph `B(n)`.\n\n The vertices of the bubble sort graph are the set of permutations\n on `n` symbols. Two vertices are adjacent if one can be obtained\n from the other by swapping the labels in the `i`-th and `(i+1)`-th\n positions for `1 \\leq i ... |
def chang_graphs():
"\n Return the three Chang graphs.\n\n Three of the four strongly regular graphs of parameters `(28,12,6,4)` are\n called the Chang graphs. The fourth is the line graph of `K_8`. For more\n information about the Chang graphs, see the :wikipedia:`Chang_graphs` or\n https://www.wi... |
def CirculantGraph(n, adjacency):
'\n Returns a circulant graph with n nodes.\n\n A circulant graph has the property that the vertex `i` is connected\n with the vertices `i+j` and `i-j` for each j in ``adjacency``.\n\n INPUT:\n\n\n - ``n`` - number of vertices in the graph\n\n - ``adjacency`` ... |
def CubeGraph(n, embedding=1):
"\n Return the `n`-cube graph, also called the hypercube in `n` dimensions.\n\n The hypercube in `n` dimension is build upon the binary strings on `n` bits,\n two of them being adjacent if they differ in exactly one bit. Hence, the\n distance between two vertices in the ... |
def GoethalsSeidelGraph(k, r):
"\n Returns the graph `\\text{Goethals-Seidel}(k,r)`.\n\n The graph `\\text{Goethals-Seidel}(k,r)` comes from a construction presented\n in Theorem 2.4 of [GS1970]_. It relies on a :func:`(v,k)-BIBD\n <sage.combinat.designs.bibd.balanced_incomplete_block_design>` with `r... |
def DorogovtsevGoltsevMendesGraph(n):
'\n Construct the n-th generation of the Dorogovtsev-Goltsev-Mendes\n graph.\n\n EXAMPLES::\n\n sage: G = graphs.DorogovtsevGoltsevMendesGraph(8) # needs networkx\n sage: G.size() ... |
def FoldedCubeGraph(n):
'\n Returns the folded cube graph of order `2^{n-1}`.\n\n The folded cube graph on `2^{n-1}` vertices can be obtained from a cube\n graph on `2^n` vertices by merging together opposed\n vertices. Alternatively, it can be obtained from a cube graph on\n `2^{n-1}` vertices by ... |
def FriendshipGraph(n):
'\n Return the friendship graph `F_n`.\n\n The friendship graph is also known as the Dutch windmill graph. Let\n `C_3` be the cycle graph on 3 vertices. Then `F_n` is constructed by\n joining `n \\geq 1` copies of `C_3` at a common vertex. If `n = 1`,\n then `F_1` is isomorp... |
def FuzzyBallGraph(partition, q):
'\n Construct a Fuzzy Ball graph with the integer partition\n ``partition`` and ``q`` extra vertices.\n\n Let `q` be an integer and let `m_1,m_2,...,m_k` be a set of positive\n integers. Let `n=q+m_1+...+m_k`. The Fuzzy Ball graph with partition\n `m_1,m_2,...,m_... |
def FibonacciTree(n):
'\n Return the graph of the Fibonacci Tree `F_{i}` of order `n`.\n\n The Fibonacci tree `F_{i}` is recursively defined as the tree\n with a root vertex and two attached child trees `F_{i-1}` and\n `F_{i-2}`, where `F_{1}` is just one vertex and `F_{0}` is empty.\n\n INPUT:\n\n... |
def GeneralizedPetersenGraph(n, k):
'\n Returns a generalized Petersen graph with `2n` nodes. The variables\n `n`, `k` are integers such that `n>2` and `0<k\\leq\\lfloor(n-1)`/`2\\rfloor`\n\n For `k=1` the result is a graph isomorphic to the circular ladder graph\n with the same `n`. The regular Peter... |
def IGraph(n, j, k):
'\n Return an I-graph with `2n` nodes.\n\n The I-Graph family as been proposed in [BCMS1988]_ as a generalization of\n the generalized Petersen graphs. The variables `n`, `j`, `k` are integers\n such that `n > 2` and `0 < j, k \\leq \\lfloor (n - 1) / 2 \\rfloor`.\n When `j = ... |
def DoubleGeneralizedPetersenGraph(n, k):
"\n Return a double generalized Petersen graph with `4n` nodes.\n\n The double generalized Petersen graphs is a family of graphs proposed in\n [ZF2012]_ as a variant of generalized Petersen graphs. The variables `n`,\n `k` are integers such that `n > 2` and `... |
def RoseWindowGraph(n, a, r):
'\n Return a rose window graph with `2n` nodes.\n\n The rose window graphs is a family of tetravalant graphs introduced in\n [Wilson2008]_. The parameters `n`, `a` and `r` are integers such that\n `n > 2`, `1 \\leq a, r < n`, and `r \\neq n / 2`.\n\n INPUT:\n\n - ``... |
def TabacjnGraph(n, a, b, r):
'\n Return a Tabačjn graph with `2n` nodes.\n\n The Tabačjn graphs is a family of pentavalent bicirculants graphs proposed\n in [AHKOS2014]_ as a generalization of generalized Petersen graphs. The\n parameters `n`, `a`, `b`, `r` are integers such that `n \\geq 3`, `1 \\le... |
def HararyGraph(k, n):
'\n Returns the Harary graph on `n` vertices and connectivity `k`, where\n `2 \\leq k < n`.\n\n A `k`-connected graph `G` on `n` vertices requires the minimum degree\n `\\delta(G)\\geq k`, so the minimum number of edges `G` should have is\n `\\lceil kn/2\\rceil`. Harary graph... |
def HyperStarGraph(n, k):
"\n Return the hyper-star graph `HS(n, k)`.\n\n The vertices of the hyper-star graph are the set of binary strings of length\n `n` which contain `k` 1s. Two vertices, `u` and `v`, are adjacent only if\n `u` can be obtained from `v` by swapping the first bit with a different\n... |
def LCFGraph(n, shift_list, repeats):
'\n Return the cubic graph specified in LCF notation.\n\n LCF (Lederberg-Coxeter-Fruchte) notation is a concise way of\n describing cubic Hamiltonian graphs. The way a graph is constructed\n is as follows. Since there is a Hamiltonian cycle, we first create\n a... |
def MycielskiGraph(k=1, relabel=True):
'\n Returns the `k`-th Mycielski Graph.\n\n The graph `M_k` is triangle-free and has chromatic number\n equal to `k`. These graphs show, constructively, that there\n are triangle-free graphs with arbitrarily high chromatic\n number.\n\n The Mycielski graphs... |
def MycielskiStep(g):
'\n Perform one iteration of the Mycielski construction.\n\n See the documentation for ``MycielskiGraph`` which uses this\n method. We expose it to all users in case they may find it\n useful.\n\n EXAMPLE. One iteration of the Mycielski step applied to the\n 5-cycle yields ... |
def NKStarGraph(n, k):
'\n Returns the (n,k)-star graph.\n\n The vertices of the (n,k)-star graph are the set of all arrangements of\n n symbols into labels of length k. There are two adjacency rules for\n the (n,k)-star graph. First, two vertices are adjacent if one can be\n obtained from the othe... |
def NStarGraph(n):
'\n Returns the n-star graph.\n\n The vertices of the n-star graph are the set of permutations on n\n symbols. There is an edge between two vertices if their labels differ\n only in the first and one other position.\n\n INPUT:\n\n - ``n``\n\n EXAMPLES::\n\n sage: g ... |
def OddGraph(n):
'\n Returns the Odd Graph with parameter `n`.\n\n The Odd Graph with parameter `n` is defined as the\n Kneser Graph with parameters `2n-1,n-1`.\n Equivalently, the Odd Graph is the graph whose vertices\n are the `n-1`-subsets of `[0,1,\\dots,2(n-1)]`, and such\n that two vertice... |
def PaleyGraph(q):
'\n Paley graph with `q` vertices\n\n Parameter `q` must be the power of a prime number and congruent\n to 1 mod 4.\n\n EXAMPLES::\n\n sage: G = graphs.PaleyGraph(9); G # needs sage.rings.finite_rings\n Paley graph with par... |
def PasechnikGraph(n):
'\n Pasechnik strongly regular graph on `(4n-1)^2` vertices\n\n A strongly regular graph with parameters of the orthogonal array graph\n :func:`~sage.graphs.graph_generators.GraphGenerators.OrthogonalArrayBlockGraph`,\n also known as pseudo Latin squares graph `L_{2n-1}(4n-1)`, ... |
def SquaredSkewHadamardMatrixGraph(n):
'\n Pseudo-`OA(2n,4n-1)`-graph from a skew Hadamard matrix of order `4n`\n\n A strongly regular graph with parameters of the orthogonal array graph\n :func:`~sage.graphs.graph_generators.GraphGenerators.OrthogonalArrayBlockGraph`,\n also known as pseudo Latin squ... |
def SwitchedSquaredSkewHadamardMatrixGraph(n):
'\n A strongly regular graph in Seidel switching class of\n `SquaredSkewHadamardMatrixGraph`\n\n A strongly regular graph in the :meth:`Seidel switching\n <Graph.seidel_switching>` class of the disjoint union of a 1-vertex graph\n and the one produced ... |
def HanoiTowerGraph(pegs, disks, labels=True, positions=True):
'\n Returns the graph whose vertices are the states of the\n Tower of Hanoi puzzle, with edges representing legal moves between states.\n\n INPUT:\n\n - ``pegs`` - the number of pegs in the puzzle, 2 or greater\n - ``disks`` - the numbe... |
def line_graph_forbidden_subgraphs():
'\n Returns the 9 forbidden subgraphs of a line graph.\n\n See the :wikipedia:`Line_graph` for more information.\n\n The graphs are returned in the ordering given by the Wikipedia\n drawing, read from left to right and from top to bottom.\n\n EXAMPLES::\n\n ... |
def petersen_family(generate=False):
'\n Returns the Petersen family\n\n The Petersen family is a collection of 7 graphs which are the forbidden\n minors of the linklessly embeddable graphs. For more information see the\n :wikipedia:`Petersen_family`.\n\n INPUT:\n\n - ``generate`` (boolean) -- w... |
def SierpinskiGasketGraph(n):
'\n Return the Sierpinski Gasket graph of generation `n`.\n\n All vertices but 3 have valence 4.\n\n INPUT:\n\n - `n` -- an integer\n\n OUTPUT:\n\n a graph `S_n` with `3 (3^{n-1}+1)/2` vertices and\n `3^n` edges, closely related to the famous Sierpinski triangle\... |
def GeneralizedSierpinskiGraph(G, k, stretch=None):
'\n Return the generalized Sierpinski graph of `G` of dimension `k`.\n\n Generalized Sierpinski graphs have been introduced in [GKP2011]_ to\n generalize the notion of Sierpinski graphs [KM1997]_.\n\n Given a graph `G = (V, E)` of order `n` and a par... |
def WheelGraph(n):
"\n Returns a Wheel graph with n nodes.\n\n A Wheel graph is a basic structure where one node is connected to all other\n nodes and those (outer) nodes are connected cyclically.\n\n PLOTTING: Upon construction, the position dictionary is filled to override\n the spring-layout alg... |
def WindmillGraph(k, n):
'\n Return the Windmill graph `Wd(k, n)`.\n\n The windmill graph `Wd(k, n)` is an undirected graph constructed for `k \\geq\n 2` and `n \\geq 2` by joining `n` copies of the complete graph `K_k` at a\n shared vertex. It has `(k-1)n+1` vertices and `nk(k-1)/2` edges, girth 3 (i... |
def trees(vertices):
"\n Returns a generator of the distinct trees on a fixed number of vertices.\n\n INPUT:\n\n - ``vertices`` - the size of the trees created.\n\n OUTPUT:\n\n A generator which creates an exhaustive, duplicate-free listing\n of the connected free (unlabeled) trees with ``verti... |
def nauty_gentreeg(options='', debug=False):
'\n Return a generator which creates non-isomorphic trees from nauty\'s gentreeg\n program.\n\n INPUT:\n\n - ``options`` -- string (default: ``""``); a string passed to ``gentreeg``\n as if it was run at a system command line. At a minimum, you *must* ... |
def RingedTree(k, vertex_labels=True):
"\n Return the ringed tree on k-levels.\n\n A ringed tree of level `k` is a binary tree with `k` levels (counting\n the root as a level), in which all vertices at the same level are connected\n by a ring.\n\n More precisely, in each layer of the binary tree (i... |
def MathonPseudocyclicMergingGraph(M, t):
"\n Mathon's merging of classes in a pseudo-cyclic 3-class association scheme\n\n Construct strongly regular graphs from p.97 of [BL1984]_.\n\n INPUT:\n\n - ``M`` -- the list of matrices in a pseudo-cyclic 3-class association scheme.\n The identity matrix... |
def MathonPseudocyclicStronglyRegularGraph(t, G=None, L=None):
'\n Return a strongly regular graph on `(4t+1)(4t-1)^2` vertices from\n [Mat1978]_.\n\n Let `4t-1` be a prime power, and `4t+1` be such that there exists\n a strongly regular graph `G` with parameters `(4t+1,2t,t-1,t)`. In\n particular,... |
def TuranGraph(n, r):
'\n Returns the Turan graph with parameters `n, r`.\n\n Turan graphs are complete multipartite graphs with `n` vertices and `r`\n subsets, denoted `T(n,r)`, with the property that the sizes of the subsets\n are as close to equal as possible. The graph `T(n,r)` will have `n \\pmod... |
def MuzychukS6Graph(n, d, Phi='fixed', Sigma='fixed', verbose=False):
"\n Return a strongly regular graph of S6 type from [Muz2007]_ on\n `n^d((n^d-1)/(n-1)+1)` vertices.\n\n The construction depends upon a number of parameters, two of them, `n` and\n `d`, mandatory, and `\\Phi` and `\\Sigma` mappings... |
def CubeConnectedCycle(d):
'\n Return the cube-connected cycle of dimension `d`.\n\n The cube-connected cycle of order `d` is the `d`-dimensional hypercube\n with each of its vertices replaced by a cycle of length `d`. This graph has\n order `d \\times 2^d`.\n The construction is as follows:\n C... |
def IntervalGraph(intervals, points_ordered=False):
'\n Return the graph corresponding to the given intervals.\n\n An interval graph is built from a list `(a_i,b_i)_{1\\leq i \\leq n}` of\n intervals : to each interval of the list is associated one vertex, two\n vertices being adjacent if the two corr... |
def PermutationGraph(second_permutation, first_permutation=None):
'\n Build a permutation graph from one permutation or from two lists.\n\n Definition:\n\n If `\\sigma` is a permutation of `\\{ 1, 2, \\ldots, n \\}`, then the\n permutation graph of `\\sigma` is the graph on vertex set\n `\\{ 1, 2, ... |
def ToleranceGraph(tolrep):
'\n Return the graph generated by the tolerance representation ``tolrep``.\n\n The tolerance representation ``tolrep`` is described by the list\n `((l_0,r_0,t_0), (l_1,r_1,t_1), \\ldots, (l_k,r_k,t_k))` where `I_i =\n (l_i,r_i)` denotes a closed interval on the real line wi... |
def OrthogonalArrayBlockGraph(k, n, OA=None):
"\n Return the graph of an `OA(k,n)`.\n\n The intersection graph of the blocks of a transversal design with parameters\n `(k,n)`, or `TD(k,n)` for short, is a strongly regular graph (unless it is a\n complete graph). Its parameters `(v,k',\\lambda,\\mu)` a... |
def IntersectionGraph(S):
'\n Return the intersection graph of the family `S`\n\n The intersection graph of a family `S` is a graph `G` with `V(G)=S` such\n that two elements `s_1,s_2\\in S` are adjacent in `G` if and only if `s_1\\cap\n s_2\\neq \\emptyset`.\n\n INPUT:\n\n - ``S`` -- a list of ... |
def TetrahedralGraph():
'\n Return a tetrahedral graph (with 4 nodes).\n\n A tetrahedron is a 4-sided triangular pyramid. The tetrahedral graph\n corresponds to the connectivity of the vertices of the tetrahedron. This\n graph is equivalent to a wheel graph with 4 nodes and also a complete graph\n ... |
def HexahedralGraph():
'\n Return a hexahedral graph (with 8 nodes).\n\n A regular hexahedron is a 6-sided cube. The hexahedral graph corresponds to\n the connectivity of the vertices of the hexahedron. This graph is\n equivalent to a 3-cube.\n\n PLOTTING: The Hexahedral graph should be viewed in 3... |
def OctahedralGraph():
'\n Return an Octahedral graph (with 6 nodes).\n\n The regular octahedron is an 8-sided polyhedron with triangular faces. The\n octahedral graph corresponds to the connectivity of the vertices of the\n octahedron. It is the line graph of the tetrahedral graph. The octahedral is\... |
def IcosahedralGraph():
'\n Return an Icosahedral graph (with 12 nodes).\n\n The regular icosahedron is a 20-sided triangular polyhedron. The icosahedral\n graph corresponds to the connectivity of the vertices of the icosahedron. It\n is dual to the dodecahedral graph. The icosahedron is symmetric, so... |
def DodecahedralGraph():
'\n Return a Dodecahedral graph (with 20 nodes)\n\n The dodecahedral graph is cubic symmetric, so the spring-layout algorithm\n will be very effective for display. It is dual to the icosahedral graph.\n\n PLOTTING: The Dodecahedral graph should be viewed in 3 dimensions. We\n ... |
def RandomGNP(n, p, seed=None, fast=True, algorithm='Sage'):
'\n Returns a random graph on `n` nodes. Each edge is inserted independently\n with probability `p`.\n\n INPUT:\n\n - ``n`` -- number of nodes of the graph\n\n - ``p`` -- probability of an edge\n\n - ``seed`` -- a ``random.Random`` see... |
def RandomBarabasiAlbert(n, m, seed=None):
'\n Return a random graph created using the Barabasi-Albert preferential\n attachment model.\n\n A graph with `m` vertices and no edges is initialized, and a graph of `n`\n vertices is grown by attaching new vertices each with `m` edges that are\n attached... |
def RandomBipartite(n1, n2, p, set_position=False, seed=None):
'\n Returns a bipartite graph with `n1+n2` vertices such that any edge\n from `[n1]` to `[n2]` exists with probability `p`.\n\n INPUT:\n\n - ``n1, n2`` -- Cardinalities of the two sets\n\n - ``p`` -- Probability for an edge to exist\n\n... |
def RandomRegularBipartite(n1, n2, d1, set_position=False, seed=None):
'\n Return a random regular bipartite graph on `n1 + n2` vertices.\n\n The bipartite graph has `n1 * d1` edges. Hence, `n2` must divide `n1 * d1`.\n Each vertex of the set of cardinality `n1` has degree `d1` (which can be at\n most... |
def RandomBlockGraph(m, k, kmax=None, incidence_structure=False, seed=None):
'\n Return a Random Block Graph.\n\n A block graph is a connected graph in which every biconnected component\n (block) is a clique.\n\n .. SEEALSO::\n\n - :wikipedia:`Block_graph` for more details on these graphs\n ... |
def RandomBoundedToleranceGraph(n, seed=None):
'\n Return a random bounded tolerance graph.\n\n The random tolerance graph is built from a random bounded tolerance\n representation by using the function `ToleranceGraph`. This representation\n is a list `((l_0,r_0,t_0), (l_1,r_1,t_1), ..., (l_k,r_k,t_k... |
def RandomGNM(n, m, dense=False, seed=None):
"\n Returns a graph randomly picked out of all graphs on n vertices\n with m edges.\n\n INPUT:\n\n - ``n`` -- number of vertices.\n\n - ``m`` -- number of edges.\n\n - ``dense`` -- whether to use NetworkX's\n :func:`dense_gnm_random_graph` or :fu... |
def RandomNewmanWattsStrogatz(n, k, p, seed=None):
'\n Return a Newman-Watts-Strogatz small world random graph on `n` vertices.\n\n From the NetworkX documentation: first create a ring over `n` nodes. Then\n each node in the ring is connected with its `k` nearest neighbors. Then\n shortcuts are creat... |
def RandomHolmeKim(n, m, p, seed=None):
'\n Return a random graph generated by the Holme and Kim algorithm for\n graphs with power law degree distribution and approximate average\n clustering.\n\n INPUT:\n\n - ``n`` -- number of vertices\n\n - ``m`` -- number of random edges to add for each new ... |
def RandomIntervalGraph(n, seed=None):
'\n Returns a random interval graph.\n\n An interval graph is built from a list `(a_i,b_i)_{1\\leq i \\leq n}`\n of intervals : to each interval of the list is associated one\n vertex, two vertices being adjacent if the two corresponding\n intervals intersect.... |
def growing_subtrees(T, k):
'\n Return a list of the vertex sets of ``n`` randomly chosen subtrees of ``T``.\n\n For a tree of order `n`, the collection contains `n` subtrees with maximum\n order `k` and average order `\\frac{k + 1}{2}`.\n\n This method is part of\n :meth:`~sage.graphs.generators.r... |
def connecting_nodes(T, l):
'\n Return a list of the vertex sets of ``n`` randomly chosen subtrees of ``T``.\n\n This method is part of\n :meth:`~sage.graphs.generators.random.RandomChordalGraph`.\n\n ALGORITHM:\n\n For each subtree `T_i`, we first select `k_i` nodes of `T`, where `k_i` is a\n r... |
def pruned_tree(T, f, s):
'\n Return a list of the vertex sets of ``n`` randomly chosen subtrees of ``T``.\n\n This method is part of\n :meth:`~sage.graphs.generators.random.RandomChordalGraph`.\n\n ALGORITHM:\n\n For each subtree `T_i`, it randomly selects a fraction `f` of the edges on\n the t... |
def RandomChordalGraph(n, algorithm='growing', k=None, l=None, f=None, s=None, seed=None):
'\n Return a random chordal graph of order ``n``.\n\n A Graph `G` is said to be chordal if it contains no induced hole (a cycle of\n length at least 4). Equivalently, `G` is chordal if it has a perfect\n elimina... |
def RandomLobster(n, p, q, seed=None):
'\n Returns a random lobster.\n\n A lobster is a tree that reduces to a caterpillar when pruning all\n leaf vertices. A caterpillar is a tree that reduces to a path when\n pruning all leaf vertices (q=0).\n\n INPUT:\n\n - ``n`` - expected number of vertices... |
def RandomTree(n, seed=None):
"\n Returns a random tree on `n` nodes numbered `0` through `n-1`.\n\n By Cayley's theorem, there are `n^{n-2}` trees with vertex\n set `\\{0,1,...,n-1\\}`. This constructor chooses one of these uniformly\n at random.\n\n ALGORITHM:\n\n The algorithm works by genera... |
def RandomTreePowerlaw(n, gamma=3, tries=1000, seed=None):
'\n Return a tree with a power law degree distribution, or ``False`` on failure.\n\n From the NetworkX documentation: a trial power law degree sequence is chosen\n and then elements are swapped with new elements from a power law\n distribution... |
def RandomRegular(d, n, seed=None):
'\n Return a random `d`-regular graph on `n` vertices, or ``False`` on failure.\n\n Since every edge is incident to two vertices, `n\\times d` must be even.\n\n INPUT:\n\n - ``d`` -- degree\n\n - ``n`` -- number of vertices\n\n - ``seed`` -- a ``random.Random`... |
def RandomShell(constructor, seed=None):
'\n Return a random shell graph for the constructor given.\n\n INPUT:\n\n - ``constructor`` -- a list of 3-tuples `(n, m, d)`, each representing a\n shell, where:\n\n - ``n`` -- the number of vertices in the shell\n\n - ``m`` -- the number of edges ... |
def RandomToleranceGraph(n, seed=None):
'\n Return a random tolerance graph.\n\n The random tolerance graph is built from a random tolerance representation\n by using the function `ToleranceGraph`. This representation is a list\n `((l_0,r_0,t_0), (l_1,r_1,t_1), ..., (l_k,r_k,t_k))` where `k = n-1` and... |
def _auxiliary_random_forest_word(n, k):
'\n Return a random word used to generate random triangulations.\n\n INPUT:\n\n - ``n`` -- an integer\n\n - ``k`` -- an integer\n\n OUTPUT:\n\n A binary sequence `w` of length `4n+2k-4` with `n` ones, such that any\n proper prefix `u` of `w` satisfies ... |
def _contour_and_graph_from_words(pendant_word, forest_word):
'\n Return the contour word and the graph of inner vertices of the `k`-gonal\n forest associated with the words ``pendant_word`` and ``forest_word``.\n\n INPUT:\n\n - ``pendant_word`` -- a word with `k-1` zeros and `k-3` ones\n\n - ``for... |
def RandomTriangulation(n, set_position=False, k=3, seed=None):
"\n Return a random inner triangulation of an outer face of degree ``k`` with\n ``n`` vertices in total.\n\n An inner triangulation is a plane graph all of whose faces (except the\n outer/unbounded face) are triangles (3-cycles).\n\n I... |
def blossoming_contour(t, shift=0, seed=None):
"\n Return a random blossoming of a binary tree `t`, as a contour word.\n\n This is doing several things simultaneously:\n\n - complete the binary tree, by adding leaves labelled ``xb``,\n - add a vertex labelled ``n`` at the middle of every inner\n ... |
def RandomBicubicPlanar(n, seed=None):
"\n Return the graph of a random bipartite cubic map with `3 n` edges.\n\n INPUT:\n\n `n` -- an integer (at least `1`)\n\n - ``seed`` -- a ``random.Random`` seed or a Python ``int`` for the random\n number generator (default: ``None``)\n\n OUTPUT:\n\n ... |
def RandomUnitDiskGraph(n, radius=0.1, side=1, seed=None):
'\n Return a random unit disk graph of order `n`.\n\n A unit disk graph is the intersection graph of a family of unit disks in the\n Euclidean plane. That is a graph with one vertex per disk of the family and\n an edge between two vertices whe... |
def HarborthGraph():
'\n Return the Harborth Graph.\n\n The Harborth graph has 104 edges and 52 vertices, and is the smallest known\n example of a 4-regular matchstick graph. For more information, see the\n :wikipedia:`Harborth_graph`.\n\n EXAMPLES::\n\n sage: g = graphs.HarborthGraph(); g\n... |
def HarriesGraph(embedding=1):
"\n Return the Harries Graph.\n\n The Harries graph is a Hamiltonian 3-regular graph on 70 vertices.\n See the :wikipedia:`Harries_graph`.\n\n The default embedding here is to emphasize the graph's 4 orbits. This graph\n actually has a funny construction. The followin... |
def HarriesWongGraph(embedding=1):
"\n Return the Harries-Wong Graph.\n\n See the :wikipedia:`Harries-Wong_graph`.\n\n *About the default embedding:*\n\n The default embedding is an attempt to emphasize the graph's 8 (!!!)\n different orbits. In order to understand this better, one can picture the\... |
def WellsGraph():
'\n Return the Wells graph.\n\n For more information on the Wells graph (also called Armanios-Wells graph),\n see `this page <https://www.win.tue.nl/~aeb/graphs/Wells.html>`_.\n\n The implementation follows the construction given on page 266 of [BCN1989]_.\n This requires to creat... |
def Cell600(embedding=1):
'\n Return the 600-Cell graph.\n\n This is the adjacency graph of the 600-cell. It has 120 vertices and 720\n edges. For more information, see the :wikipedia:`600-cell`.\n\n INPUT:\n\n - ``embedding`` -- integer (default: ``1``); two different embeddings for a\n plot\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.