Module stable_graphs

class cvolume.stable_graphs.LabeledStableGraph(edges, loops, kappa)[source]

Bases: object

Aut()[source]

Return the order of the group of automorphisms of this Labeled Stable Graph.

EXAMPLES:

Here we compute the order of automorphism group of a single vertex graph with two loops:

sage: from cvolume import LabeledStableGraph
sage: edges, loops, kappa = [], [2], [[3, 3, 1, -1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.Aut()
8

Here we compute the order of automorphism group of a two vertex graph with no loops, but a symmetry due to isomorphic vertices:

sage: edges, loops, kappa = [(0, 1, 1)], [0, 0], [[3, -1],[3, -1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.Aut()
2

Here we compute the order of automorphism group of a two vertex graph with no loops, but five edges between non-isomorphic vertices:

sage: edges, loops, kappa = [(0, 1, 5)], [0, 0], [[5, 1],[7, -1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.Aut()
120
edge_degenerations()[source]

Return the set of all Labeled Stable Graphs, obtained by special degenerations adding an edge to this Labeled Stable Graph. A special edge degeneration only adds an edge to the vertex with largest profile, when it’s unique. Profile is the sum of weight and length of the associated zeros partition.

EXAMPLE:

Here is an example of all degenerations obtained by adding an adge:

sage: from cvolume import LabeledStableGraph
sage: edges, loops, kappa = [], [1], [[3, 3, 1, 1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.edge_degenerations()
{Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 1), kappa = ((1, 1), (3, 3)),
 Labeled Stable Graph with edges = ((0, 1, 1),), loops = (1, 0), kappa = ((1, 1), (3, 3)),
 Labeled Stable Graph with edges = ((0, 1, 2),), loops = (0, 0), kappa = ((3, 1), (3, 1))}

Here is another example of special edge-degenerations:

sage: edges, loops, kappa = [(0, 1, 1)], [0, 0], [[1, 1],[3, 1, 1, 1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.edge_degenerations()
{Labeled Stable Graph with edges = ((0, 2, 1), (1, 2, 1)), loops = (0, 0, 0), kappa = ((1, 1), (1, 1), (3, 1))}
loop_degenerations()[source]

Return the set of all Labeled Stable Graphs, obtained by the degenerations adding a loop to this Labeled Stable Graph.

EXAMPLE:

Here we compute all degenerations obtained by adding a loop to the stable graph:

sage: from cvolume import LabeledStableGraph
sage: edges, loops, kappa = [(0, 1, 2), (0, 2, 1), (1, 2, 1)], [0, 1, 0], [[1, 1], [5, 3, 1, 1], [7, 1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.loop_degenerations()
{Labeled Stable Graph with edges = ((0, 1, 2), (0, 2, 1), (1, 2, 1)), loops = (0, 1, 1), kappa = ((1, 1), (5, 3, 1, 1), (7, 1)),
 Labeled Stable Graph with edges = ((0, 1, 2), (0, 2, 1), (1, 2, 1)), loops = (0, 2, 0), kappa = ((1, 1), (5, 3, 1, 1), (7, 1))}
one_step_degenerations()[source]

Return the set of all Labeled Stable Graphs, obtained by special one step degenerations of this Labeled Stable Graph. A special degeneration is adding a loop to a single vertex graph, or adding an edge to any graph.

EXAMPLES:

Here we compute all special one step degenerations of a graph with a single vertex labeled by a stratum \(\mathcal{Q}(3,3,1,1)\) with a single loop attached to it:

sage: from cvolume import LabeledStableGraph
sage: edges,loops,kappa = [], [1], [[3, 3, 1, 1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.one_step_degenerations()
{Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 1), kappa = ((1, 1), (3, 3)),
 Labeled Stable Graph with edges = ((0, 1, 1),), loops = (1, 0), kappa = ((1, 1), (3, 3)),
 Labeled Stable Graph with edges = ((0, 1, 2),), loops = (0, 0), kappa = ((3, 1), (3, 1)),
 Labeled Stable Graph with edges = (), loops = (2,), kappa = ((3, 3, 1, 1),)}

Here we start with a single vertex of genus 0 and therefore obtain no degenerations:

sage: edges,loops,kappa = [], [2], [[5,-1]]
sage: stg = LabeledStableGraph(edges,loops,kappa)
sage: stg.one_step_degenerations()
set()         
vertex_deg(v)[source]

Return the total number of non-loop edges (counted with multiplicities) at the vertex v of this Labeled Stable Graph.

EXAMPLE:

Here is an example of vertices degrees:

sage: from cvolume.stable_graphs import LabeledStableGraph
sage: stg = LabeledStableGraph([(0, 1, 2), (0, 2, 1), (1, 2, 5)], [0, 0, 0], [[5, 1], [7, 7], [11, 1]])
sage: stg.vertex_deg(0), stg.vertex_deg(1), stg.vertex_deg(2)
(3, 7, 6)
cvolume.stable_graphs.canonical(edges, loops, kappa, graph)[source]

Return a 4-tuple (edges,loops,kappa,graph) of immutable objects, corresponding to the canonical representative of the class of isomorphism of the given labeled stable graph, where only vertices with the same number of loops and zero orders are allowed to permute and only edges of the same weight are allowed to permute.

EXAMPLES:

Here is an example of canonical representative corresponding to a graph. Note that vertex 1 is switched with vertex 2:

sage: from cvolume.stable_graphs import canonical
sage: edges, loops, kappa = [(0, 1, 1), (0, 2, 1),(2, 1, 1)], [1, 2, 1], [[3, 1],[7, 5],[3, 1]]
sage: graph = Graph(edges)
sage: canonical(edges,loops,kappa,graph)
(((0, 1, 1), (0, 2, 1), (1, 2, 1)),
 (1, 1, 2),
 ((3, 1), (3, 1), (7, 5)),
 Graph on 3 vertices)

Another example of canonical representative. Note that orders of zeros in stratum are sorted in reverse:

sage: edges, loops, kappa = [(0, 1, 1)], [1, 1], [[1, 3], [1, 3, 5, -1]]
sage: graph = Graph(edges)
sage: canonical(edges,loops,kappa,graph)
(((0, 1, 1),), (1, 1), ((3, 1), (5, 3, 1, -1)), Graph on 2 vertices)
cvolume.stable_graphs.k_to_p(edges, loops, kappa, graph)[source]

Return a canonical partition of vertices of the graph into lists grouped by the same number of loops and orders of zeroes. The order is lexicographical with respect to kappa -> loops -> edges.

EXAMPLE:

Here is an example of vertices grouped and sorted according to k_to_p. The graph is a triangle with no loops, by the third vertex is labeled differently from the other two:

sage: from cvolume.stable_graphs import k_to_p
sage: edges, loops, kappa = [(0, 1, 1), (0, 2, 1), (1, 2, 1)], [0, 0, 0], [[1, 1], [1, 1], [3, 1]]
sage: graph = Graph(edges)
sage: k_to_p(edges,loops,kappa,graph)
[[0, 1], [2]]

Here is a more complicated example of k_to_p:

sage: from cvolume.stable_graphs import k_to_p
sage: edges, loops, kappa = [(0, 1, 1), (0, 3, 1), (1, 6, 1), (2, 3, 1), (2, 5, 1), (4, 5, 1), (4, 6, 1)], [0, 0, 3, 2, 2, 0, 1], [(1, -1), (1, -1), (1, -1), (1, 1), (1, 1), (3, 1), (3, 3, 1)]; 
sage: graph = Graph(edges)
sage: k_to_p(edges,loops,kappa,graph)
[[0, 1], [2], [3, 4], [5], [6]]
cvolume.stable_graphs.stable_lab_graphs(stratum, by_codim=False, one_vertex=False, verbose=False)[source]

Return the set of all Labeled Stable Graphs given by the stratum.

INPUT:

  • stratum – list of orders of zeroes (including -1 for simple poles) of the stratum
  • by_codim – boolean (default False), when True returns the list of sets of stable graphs organized by codimension
  • one_vertex – boolean (default False), when True only returns the set of one-vertex stable graphs
  • verbose – boolean (default False), when True prints progress, total time and the number of stable graphs

OUTPUT:

  • graphs – set of Labeled Stable Graphs (if by_codim is False), or list of sets of Labeled Stable Graphs organized by codimension (if by_codim is True). In the first case we exclude original graph with no edges (codimension 0), in the second case we keep it, so that the index of the subset of stable graphs in the output list is their codimension.

EXAMPLES:

Here we generate all labeled stable graphs in stratum \(\mathcal{Q}(3,-1,-1,-1)\):

sage: from cvolume import stable_lab_graphs
sage: stable_lab_graphs([3, -1, -1, -1])
{Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 0), kappa = ((-1, -1), (3, -1)),
 Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 1), kappa = ((-1, -1), (3, -1)),
 Labeled Stable Graph with edges = (), loops = (1,), kappa = ((3, -1, -1, -1),)}

Here we generate the same graphs only organized by codimension. Note that we keep the original non-degenerate graph of the stratum as the subset at index 0:

sage: stable_lab_graphs([3, -1, -1, -1], by_codim = True)
[{Labeled Stable Graph with edges = (), loops = (0,), kappa = ((3, -1, -1, -1),)},
 {Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 0), kappa = ((-1, -1), (3, -1)),
  Labeled Stable Graph with edges = (), loops = (1,), kappa = ((3, -1, -1, -1),)},
 {Labeled Stable Graph with edges = ((0, 1, 1),), loops = (0, 1), kappa = ((-1, -1), (3, -1))}]

Here we demonstrate verbose mode by generating stable graphs for stratum \(\mathcal{Q}(3,1,1,-1)\):

sage: graphs = stable_lab_graphs([3, 1, 1, -1], verbose = True)
Generated 2 codimension 1 graphs in ... s
Generated 4 codimension 2 graphs in ... s
Generated 3 codimension 3 graphs in ... s
The total number of stable graphs for stratum [3, 1, 1, -1] is: 9.
Generated all stable graphs for stratum [3, 1, 1, -1] in: ... s

Here we compute the number of labeled stable graphs for stratum \(\mathcal{Q}(3,1,1,1,1,1)\):

sage: len(stable_lab_graphs([3, 1, 1, 1, 1, 1]))
31

Here we generate only one-vertex labeled stable graphs for stratum \(\mathcal{Q}(3,1,1,1,1,1)\):

sage: stable_lab_graphs([3, 1, 1, 1, 1, 1], one_vertex = True)
{Labeled Stable Graph with edges = (), loops = (1,), kappa = ((3, 1, 1, 1, 1, 1),),
 Labeled Stable Graph with edges = (), loops = (2,), kappa = ((3, 1, 1, 1, 1, 1),),
 Labeled Stable Graph with edges = (), loops = (3,), kappa = ((3, 1, 1, 1, 1, 1),)}