Ticket #14001: trac_14001-coxeter_diagram_for_quiver_mutation_types.patch

File trac_14001-coxeter_diagram_for_quiver_mutation_types.patch, 4.2 KB (added by stumpc5, 8 years ago)
  • sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py

    # HG changeset patch
    # User Christian Stump <christian.stump at gmail.com>
    # Date 1359024606 0
    # Node ID 7472d0c7bd619b97a15c148542cde7f0c0968d90
    # Parent  5f1beb5b75e9ce83068f34d43a366256d98fb71f
    trac 14001 Implementation of Coxeter diagrams for quiver mutation types
    
    diff --git a/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py
    a b class QuiverMutationType_abstract(Unique 
    686686        """
    687687        return self._rank
    688688
     689    def coxeter_diagram(self):
     690        """
     691        Returns the Coxeter diagram of self.
     692
     693        EXAMPLES::
     694            sage: mut_type = QuiverMutationType( ['A',5] ); mut_type
     695            ['A', 5]
     696            sage: mut_type.coxeter_diagram()
     697            Coxeter diagram of rank 5
     698
     699            sage: mut_type = QuiverMutationType( ['A',[5,3],1] ); mut_type
     700            ['A', [3, 5], 1]
     701            sage: mut_type.coxeter_diagram()
     702            Coxeter diagram of rank 8
     703
     704            sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type
     705            [ ['A', 3], ['B', 3] ]
     706            sage: mut_type.coxeter_diagram()
     707            Coxeter diagram of rank 6
     708
     709            sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]); mut_type
     710            [ ['A', 3], ['B', 3], ['X', 6] ]
     711            sage: mut_type.coxeter_diagram()
     712            Coxeter diagram of rank 12
     713        """
     714        G = Graph(self._graph)
     715        for v1,v2,label in G.edges():
     716            if type(label) in [list,tuple]: label = -prod(label)
     717            elif label == 2: label = 4
     718
     719            if label is None:
     720                G.set_edge_label(v1,v2,1)
     721            elif label in [1,2]:
     722                G.set_edge_label(v1,v2,label+2)
     723            elif label == 3:
     724                G.set_edge_label(v1,v2,4)
     725            elif label == 4:
     726                G.set_edge_label(v1,v2,infinity)
     727            else:
     728                raise ValueError, "Coxeter diagrams are not defined for quiver mutation types with edge labels (b,-c) such that b*c > 4"
     729        return CoxeterDiagram(G)
     730
     731    def coxeter_matrix(self):
     732        n = self._graph.order()
     733        M = matrix(ZZ,[[2]*n]*n)
     734        for v1,v2,label in self._graph.edge_iterator():
     735            M[v1,v2] = M[v2,v1] = label
     736        for i in xrange(n):
     737            M[i,i] = 1
     738        return M
     739
    689740    @cached_method
    690741    def b_matrix(self):
    691742        """
    class QuiverMutationType_Reducible(Quive 
    19391990        comps = self.irreducible_components()
    19401991        return QuiverMutationType( [comp.dual() for comp in comps ] )
    19411992
     1993class CoxeterDiagram(SageObject):
     1994    """
     1995    This is a very basic implementation of Coxeter diagrams. Is used in QuiverMutationType and should not be called directly.
     1996    """
     1997    def __init__(self, D):
     1998        """
     1999        INPUT:
     2000
     2001        - ``D`` -- is a graph without loops or two-cycles with integral edge labels 3 and bigger and +infinity
     2002
     2003            - QuiverMutationType
     2004            - tuple or list defining a proper quiver mutation type
     2005
     2006        EXAMPLES::
     2007            sage: QuiverMutationType(['A',4],['B',6])
     2008            [ ['A', 4], ['B', 6] ]
     2009        """
     2010        self._graph = Graph(D)
     2011
     2012    def __copy__(self):
     2013        """
     2014        """
     2015        return CoxeterDiagram(self._graph)
     2016
     2017    def __hash__(self):
     2018        return hash((tuple(self._graph.vertices()), tuple(self._graph.edge_iterator(self._graph.vertices()))))
     2019
     2020    def _repr_(self):
     2021        """
     2022        """
     2023        return "Coxeter diagram of rank %s"%len(self._graph.vertices())
     2024
     2025    def show(self):
     2026        G = Graph( self._graph )
     2027        for v1,v2,label in G.edge_iterator():
     2028            if label == 3:
     2029                G.set_edge_label(v1,v2,'')
     2030        G.show(edge_labels=True)
     2031
    19422032def _construct_mutation_classes_by_rank( n ):
    19432033    r"""
    19442034    Returns a dict with keys being tuples representing regular QuiverMutationTypes
    def _edge_list_to_matrix( edges, n, m ): 
    21692259            M[v2,v1] = b
    21702260        if v2 < n:
    21712261            M[v1,v2] = a
    2172     return M
    2173  No newline at end of file
     2262    return M