Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Ticket 16310: Complete doc and add more examples/tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
egunawan committed Jun 5, 2015
1 parent 0acd113 commit c18f653
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/sage/combinat/cluster_algebra_quiver/cluster_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ def _get_map_variable_to_label(self,var):
sage: T._get_map_variable_to_label(T._boundary_edges_vars[2])
6
sage: T.mutate(0)
sage: T.cluster()[0]*T.x(3)
sage: T.cluster()[0]*T.cluster_variable(3)
(x2*x3 + x3)/x0
sage: T._get_map_variable_to_label(T.cluster()[0]*T.x(3))
sage: T._get_map_variable_to_label(T.cluster()[0]*T.cluster_variable(3))
0
sage: T._get_map_label_to_variable(0)
(x2*x3 + x3)/x0
Expand Down Expand Up @@ -1414,7 +1414,9 @@ def arc_laurent_expansion(self, crossed_arcs, first_triangle=None,
sage: c = [item for item in T.cluster()]
sage: T.arc_laurent_expansion([S.x(1),S.x(2),S.x(3)], user_labels=False)
(x0*x2^2 + 2*x0*x2 + x1*x3 + x0)/(x1*x2*x3)
sage: T.arc_laurent_expansion([c[1],c[2],c[3]], first_triangle=[c[1],T._get_map_label_to_variable(7),T._get_map_label_to_variable(4)], final_triangle=( c[0],c[3], T._get_map_label_to_variable(6) ), user_labels=False) == T.arc_laurent_expansion([S.x(1),S.x(2),S.x(3)], user_labels=False)
sage: T.arc_laurent_expansion([c[1],c[2],c[3]], first_triangle=[c[1],T._get_map_label_to_variable(7),T._get_map_label_to_variable(4)], \
....: final_triangle=( c[0],c[3], T._get_map_label_to_variable(6) ), \
....: user_labels=False) == T.arc_laurent_expansion([S.x(1),S.x(2),S.x(3)], user_labels=False)
True
sage: T.arc_laurent_expansion([1,2,3],user_labels=True) == T.arc_laurent_expansion([S.x(1),S.x(2),S.x(3)],user_labels=False)
True
Expand Down Expand Up @@ -1494,7 +1496,7 @@ def arc_laurent_expansion(self, crossed_arcs, first_triangle=None,
sage: T = ClusterTriangulation([(0,2,1),(0,4,3),(1,6,5)])
sage: S = ClusterSeed(T)
sage: S1 = S.mutate(0, inplace=False)
sage: S1.cluster_variable(0) == T.arc_laurent_expansion ([S.x(0)], user_labels=False)
sage: S1.cluster_variable(0) == T.arc_laurent_expansion ([S.cluster_variable(0)], user_labels=False)
True
sage: Tp = T.principal_extension()
sage: Sp = S.principal_extension()
Expand All @@ -1511,6 +1513,13 @@ def arc_laurent_expansion(self, crossed_arcs, first_triangle=None,
....: S.principal_extension().mutate([0,1,2], inplace=False).cluster_variable(2)
True
An example that Salomón Dominguez wrote::
sage: affineD = ClusterTriangulation([('5','6','4'),('6','7','10'),('7','1','11'),('1','5','2'),('2','3','8'),('3','4','9')], boundary_edges=['8','9','10','11'])
sage: gamma = affineD.arc_laurent_expansion(['6','7','1','2','3'],verbose=False)
sage: gamma == affineD.mutate(['3','2','1','7','6'],user_labels=True, inplace=False).cluster()[5]
True
Test bug for when a generalized arc's first cross and last cross are the same::
sage: Annulus21 = ClusterTriangulation([(1,6,7),(1,3,2),(3,5,4),(5,0,2),(0,8,9)], boundary_edges=[6,7,8,9])
Expand Down
72 changes: 72 additions & 0 deletions src/sage/combinat/cluster_algebra_quiver/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,78 @@ def matching_intersection(pmA, pmB):
return [pmB[0], pmC]

def matching_subtract(bigger_pm, smaller_pm):
"""
Return subtraction of (snake graph) perfect matchings, ``bigger_pm`` minus ``smaller_pm``.
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.surface import matching_subtract, GetMinimalMatching, matching_intersection, matching_union, GetAllMatchings
sage: affineD = ClusterTriangulation([('5','6','4'),('6','7','10'),('7','1','11'),('1','5','2'),('2','3','8'),('3','4','9')], boundary_edges=['8','9','10','11'])
sage: bandgraph = affineD.list_band_graph(['1','2','3','4','6','7','1'])
sage: Pmin = GetMinimalMatching(bandgraph)
sage: P24 = [[2, 4],\
....: [[(1, 0, 1, 0), 'RIGHT'],\
....: [(0, 1, 0, 0), 'RIGHT'],\
....: [(0, 1, 0, 1), 'ABOVE'],\
....: [(0, 0, 0, 0), 'ABOVE'],\
....: [(0, 1, 0, 1), 'ABOVE'],\
....: [(0, 0, 1, 0), 'RIGHT']]]
sage: Pmin_intersect_P24 = matching_intersection(Pmin,P24)
sage: Pmin_intersect_P24
[[2, 4],
[[(1, 0, 1, 0), 'RIGHT'],
[(0, 0, 0, 0), 'RIGHT'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'RIGHT']]]
sage: Pmin_union_P24 = matching_union(Pmin,P24)
sage: Pmin_union_P24
[[2, 4],
[[(1, 0, 1, 0), 'RIGHT'],
[(0, 1, 0, 0), 'RIGHT'],
[(1, 1, 0, 1), 'ABOVE'],
[(0, 1, 0, 1), 'ABOVE'],
[(0, 1, 0, 1), 'ABOVE'],
[(0, 1, 1, 1), 'RIGHT']]]
sage: matching_subtract(Pmin_union_P24,Pmin_intersect_P24)
[[2, 4],
[[(0, 0, 0, 0), 'RIGHT'],
[(0, 1, 0, 0), 'RIGHT'],
[(1, 1, 0, 1), 'ABOVE'],
[(0, 1, 0, 1), 'ABOVE'],
[(0, 1, 0, 1), 'ABOVE'],
[(0, 1, 1, 1), 'RIGHT']]]
sage: P025 = [[0,2,5], \
....: [[(0,1,0,1), 'RIGHT'],\
....: [(0,1,0,1), 'RIGHT'],\
....: [(0,1,0,1), 'ABOVE'],\
....: [(0,0,1,0), 'ABOVE'],\
....: [(1,0,1,0), 'ABOVE'],\
....: [(1,0,1,0), 'RIGHT']]]
sage: Pmin_intersect_P025 = matching_intersection(Pmin,P025)
sage: Pmin_intersect_P025
[[0, 2, 5],
[[(0, 0, 0, 0), 'RIGHT'],
[(0, 0, 0, 0), 'RIGHT'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'ABOVE'],
[(0, 0, 0, 0), 'RIGHT']]]
sage: Pmin_union_P025 = matching_union(Pmin,P025)
sage: Pmin_union_P025
[[0, 2, 5],
[[(1, 1, 1, 1), 'RIGHT'],
[(0, 1, 0, 1), 'RIGHT'],
[(1, 1, 0, 1), 'ABOVE'],
[(0, 1, 1, 1), 'ABOVE'],
[(1, 0, 1, 0), 'ABOVE'],
[(1, 1, 1, 1), 'RIGHT']]]
sage: matching_subtract(Pmin_union_P025,Pmin_intersect_P025) == Pmin_union_P025
True
"""
pmA = bigger_pm
pmB = smaller_pm
tile_count = len(pmA[1]) # Always put pmA as the minimal matching
Expand Down

0 comments on commit c18f653

Please sign in to comment.