Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
r""" mutation_class
This file contains helper functions for compute the mutation class of a cluster algebra or quiver.
For the compendium on the cluster algebra and quiver package see [MS2011]_
AUTHORS:
- Gregg Musiker - Christian Stump """
#***************************************************************************** # Copyright (C) 2011 Gregg Musiker <musiker@math.mit.edu> # Christian Stump <christian.stump@univie.ac.at> # # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ #*****************************************************************************
""" Returns the principal part of a matrix.
INPUT:
- ``mat`` - a matrix with at least as many rows as columns
OUTPUT:
The top square part of the matrix ``mat``.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _principal_part sage: M = Matrix([[1,2],[3,4],[5,6]]); M [1 2] [3 4] [5 6] sage: _principal_part(M) [1 2] [3 4] """ raise ValueError('The input matrix has more columns than rows.') else:
""" Returns a digraph obtained from dg with n+m vertices by mutating at vertex k.
INPUT:
- ``dg`` -- a digraph with integral edge labels with ``n+m`` vertices - ``k`` -- the vertex at which ``dg`` is mutated
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_mutate sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: dg.edges() [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -1))] sage: _digraph_mutate(dg,2,4,0).edges() [(0, 1, (1, -1)), (1, 2, (1, -1)), (3, 2, (1, -1))] """
diag_edges_new.append( (w2,v1,(b,a)) ) else:
""" Returns the digraph obtained from the matrix ``M``. In order to generate a quiver, we assume that ``M`` is skew-symmetrizable.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _matrix_to_digraph sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) Digraph on 3 vertices """
""" Turns the digraph ``dg`` into its canonical form, and returns the corresponding isomorphism, and the vertex orbits of the automorphism group.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dg_canonical_form sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges() [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -2))] sage: _dg_canonical_form(dg,4,0); dg.edges() ({0: 0, 1: 3, 2: 1, 3: 2}, [[0], [3], [1], [2]]) [(0, 3, (1, -1)), (1, 2, (1, -2)), (1, 3, (1, -1))] """ else:
""" Returns an iterator for mutation class of dg with respect to several parameters.
INPUT:
- ``dg`` -- a digraph with n+m vertices - ``depth`` -- a positive integer or infinity specifying (roughly) how many steps away from the initial seed to mutate - ``return_dig6`` -- indicates whether to convert digraph data to dig6 string data - ``show_depth`` -- if True, indicates that a running count of the depth is to be displayed - ``up_to_equivalence`` -- if True, only one digraph for each graph-isomorphism class is recorded - ``sink_source`` -- if True, only mutations at sinks or sources are applied
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _mutation_class_iter sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',[1,2],1]).digraph() sage: itt = _mutation_class_iter(dg, 3,0) sage: next(itt)[0].edges() [(0, 1, (1, -1)), (0, 2, (1, -1)), (1, 2, (1, -1))] sage: next(itt)[0].edges() [(0, 2, (1, -1)), (1, 0, (2, -2)), (2, 1, (1, -1))] """
else: else:
else: else: else: else:
""" Returns the dig6 and edge data of the digraph dg.
INPUT:
- ``dg`` -- a digraph - ``hashable`` -- (Boolean; optional; default:False) if ``True``, the edge labels are turned into a dict.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6 sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: _digraph_to_dig6(dg) ('COD?', {}) """
""" Returns the digraph obtained from the dig6 and edge data.
INPUT:
- ``dig6`` -- a pair ``(dig6, edges)`` where ``dig6`` is a string encoding a digraph and ``edges`` is a dict or tuple encoding edges
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6 sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dig6_to_digraph sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: data = _digraph_to_dig6(dg) sage: _dig6_to_digraph(data) Digraph on 4 vertices sage: _dig6_to_digraph(data).edges() [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -1))] """ else:
""" Return the matrix obtained from the dig6 and edge data.
INPUT:
- ``dig6`` -- a pair ``(dig6, edges)`` where ``dig6`` is a string encoding a digraph and ``edges`` is a dict or tuple encoding edges
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6, _dig6_to_matrix sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: data = _digraph_to_dig6(dg) sage: _dig6_to_matrix(data) [ 0 1 0 0] [-1 0 -1 0] [ 0 1 0 1] [ 0 0 -1 0] """
""" Returns True iff the digraph dg has a sink or a source at vertex v.
INPUT:
- ``dg`` -- a digraph - ``v`` -- a vertex of dg
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dg_is_sink_source sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',[1,2],1]).digraph() sage: _dg_is_sink_source(dg, 0 ) True sage: _dg_is_sink_source(dg, 1 ) True sage: _dg_is_sink_source(dg, 2 ) False """
""" Replaces edge labels in dg other than ``(1,-1)`` by this edge label, and returns the corresponding partition of the edges.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _graph_without_edge_labels sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges() [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -2))] sage: _graph_without_edge_labels(dg,range(3)); dg.edges() ([[5]], [(1, -2)]) [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 5, (1, -1)), (5, 3, (1, -1))] """ else:
""" Returns True if the input digraph has a 2-cycle and False otherwise.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _has_two_cycles sage: _has_two_cycles( DiGraph([[0,1],[1,0]])) True sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: _has_two_cycles( ClusterQuiver(['A',3]).digraph() ) False """
""" Returns True if the input data is the edge set of a digraph for a quiver (no loops, no 2-cycles, edge-labels of the specified format), and returns False otherwise.
INPUT:
- ``frozen`` -- (integer; default:0) The number of frozen vertices.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _is_valid_digraph_edge_set sage: _is_valid_digraph_edge_set( [[0,1,'a'],[2,3,(1,-1)]] ) The given digraph has edge labels which are not integral or integral 2-tuples. False sage: _is_valid_digraph_edge_set( [[0,1,None],[2,3,(1,-1)]] ) True sage: _is_valid_digraph_edge_set( [[0,1,'a'],[2,3,(1,-1)],[3,2,(1,-1)]] ) The given digraph or edge list contains oriented 2-cycles. False """
# checks if the digraph contains loops print("The given digraph or edge list contains loops.") return False
# checks if the digraph contains oriented 2-cycles
# checks if all edge labels are 'None', positive integers or tuples of positive integers
# checks if all edge labels for multiple edges are 'None' or positive integers for e in set( dg.multiple_edges(labels=False) ): if not all( i is None or ( i in ZZ and i > 0 ) for i in dg.edge_label( e[0], e[1] ) ): print("The given digraph or edge list contains multiple edges with non-integral labels.") return False
print("The number of frozen variables is larger than the number of vertices.") return False
print("The given digraph or edge list contains edges within the frozen vertices.") return False
except Exception: print("Could not even build a digraph from the input data.") return False |