Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

r""" 

Quiver mutation types 

 

AUTHORS: 

 

- Gregg Musiker (2012, initial version) 

- Christian Stump (2012, initial version) 

- Hugh Thomas (2012, initial version) 

""" 

#***************************************************************************** 

# Copyright (C) 2011 Gregg Musiker <gmusiker@gmail.com> 

# Christian Stump <christian.stump@gmail.com> 

# Hugh Thomas <hugh@math.unb.ca> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

# python3 

from __future__ import division, print_function 

from __future__ import absolute_import 

 

from six.moves import range 

 

from sage.structure.sage_object import SageObject 

from copy import copy 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.misc.all import cached_method 

from sage.rings.all import ZZ, infinity 

from sage.graphs.all import Graph, DiGraph 

from sage.arith.all import binomial, Euler_Phi 

from sage.all import prod 

from sage.matrix.all import matrix 

 

 

class QuiverMutationTypeFactory(SageObject): 

def __call__(self, *args): 

""" 

For a detailed description, see :meth:`QuiverMutationType`. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import QuiverMutationTypeFactory 

sage: QuiverMutationTypeFactory() 

QuiverMutationType 

""" 

# get data as arguments or as list/tuple 

if len( args ) == 1: 

data = args[0] 

else: 

data = args 

 

# data is a QuiverMutationType 

if isinstance(data, QuiverMutationType_Irreducible): 

return data 

elif isinstance(data, QuiverMutationType_Reducible): 

return data 

 

# check that data is a tuple or list 

if isinstance(data, tuple) and len( data ) > 0: 

pass 

elif isinstance(data, list) and len( data ) > 0: 

data = tuple( data ) 

else: 

_mutation_type_error( data ) 

 

# check for reducible types 

if all( type( data_component ) in [list,tuple,QuiverMutationType_Irreducible] for data_component in data ): 

if len( data ) == 1: return QuiverMutationType( data[0] ) 

else: 

data = tuple( QuiverMutationType(comp) for comp in data ) 

return QuiverMutationType_Reducible( *data ) 

 

# check for irreducible types 

if len(data) == 2: data = (data[0],data[1],None) 

elif len(data) == 3: pass 

else: _mutation_type_error(data) 

 

if isinstance(data[2], list): data = (data[0],data[1],tuple(data[2])) 

if isinstance(data[1], list): data = (data[0],tuple(data[1]),data[2]) 

 

# mutation type casting 

if True: 

if data == ('D',2,None): 

return QuiverMutationType( ('A',1,None), ('A',1,None) ) 

elif data == ('D',3,None): 

data = ('A',3,None) 

elif data == ('C',2,None): 

data = ('B',2,None) 

elif data == ('E',9,None): 

data = ('E',8,1) 

elif data[0] == 'A' and data[2] == 1 and isinstance(data[1], tuple) and len(data[1]) == 2 and min(data[1]) == 0: 

if max(data[1]) == 0: 

pass 

elif max(data[1]) == 1: 

data = ('A', 1,None) 

elif max(data[1]) == 2: 

return QuiverMutationType( ('A',1,None), ('A',1,None) ) 

elif max(data[1]) == 3: 

data = ('A',3,None) 

else: 

data = ('D',max(data[1]),None) 

elif data[0] == 'GR' and data[2] is None and isinstance(data[1], tuple) and len(data[1]) == 2 and data[1][1] > data[1][0]: 

if min(data[1]) > max(data[1])/2 and max(data[1]) != min(data[1])+1: 

data = (data[0],(max(data[1])-min(data[1]),max(data[1])),data[2]) 

if min(data[1]) == 2 and max(data[1]) > 3: 

data = ('A',max(data[1])-3,None) 

elif data[1] == (3,6): 

data = ('D',4,None) 

elif data[1] == (3,7): 

data = ('E',6,None) 

elif data[1] == (3,8): 

data = ('E',8,None) 

elif data[1] == (3,9): 

data = ('E',8,[1,1]) 

elif data[1] == (4,8): 

data = ('E',7,[1,1]) 

elif data == ('TR',1,None): 

data = ('A',1,None) 

elif data == ('TR',2,None): 

data = ('A',3,None) 

elif data == ('TR',3,None): 

data = ('D',6,None) 

elif data == ('TR',4,None): 

data = ('E',8,(1,1)) 

# mutation type casting from Kac conventions 

elif data == ('A',1,1): 

data = ('A',(1,1),1) 

elif data[0] == 'B' and data[2] == 1: 

if data[1] == 2: 

data = ('CC',2,1) 

elif data[1] > 2: 

data = ('BD',data[1],1) 

elif data[0] == 'B' and data[2] == -1: 

if data[1] == 2: 

data = ('BB',2,1) 

elif data[1] > 2: 

data= ('CD',data[1],1) 

elif data[0] == 'C' and data[1] > 1 and data[2] == 1: 

data = ('CC',data[1],1) 

elif data[0] == 'C' and data[1] > 1 and data[2] == -1: 

data = ('BB',data[1],1) 

elif data == ('A',2,2): 

data = ('BC',1,1) 

elif data[0] == 'A' and data[1] in ZZ and data[1] > 1 and data[1]%2 == 0 and data[2] == 2: 

data = ('BC',data[1]//2,1) 

elif data[0] == 'A' and data[1] in ZZ and data[1] > 3 and data[1]%2 == 1 and data[2] == 2: 

data = ('CD',(data[1]+1)//2,1) 

# We think of ('A',3,2) as ('D',3,2) 

elif data == ('A',3,2): 

data = ('BB',2,1) 

elif data[0] == 'D' and data[1] in ZZ and data[1] > 2 and data[2] == 2: 

data = ('BB',data[1]-1,1) 

elif data == ('E',6,2): 

data = ('F',4,-1) 

elif data == ('D',4,3): 

data = ('G',2,-1) 

elif data == ('F',4,(2,1)): 

data = ('F',4,(1,2)) 

elif data == ('G',2,(3,1)): 

data = ('G',2,(1,3)) 

elif data[0] == 'T' and data[2] is None: 

data = (data[0],tuple(sorted(data[1])),data[2]) 

r,p,q = data[1] 

if r == 1: 

data = ('A',p+q-1,None) 

elif r == p == 2: 

data = ('D',q+2,None) 

elif r == 2 and p == 3: 

if q in (3,4,5): data = ('E',q+3,None) 

elif q == 6: data = ('E',8,1) 

else: data = ('E',q+3,None) 

elif r== 2 and p == q == 4: 

data = ('E',7,1) 

elif r == p == q == 3: 

data = ('E',6,1) 

elif data[0] == 'R2' and data[2] is None and all(data[1][i] in ZZ and data[1][i] > 0 for i in [0,1]): 

data = (data[0],tuple(sorted(data[1])),data[2]) 

b,c = data[1] 

if data[1] == (1,1): 

data = ('A',2,None) 

elif data[1] == (1,2): 

data = ('B',2,None) 

elif data[1] == (1,3): 

data = ('G',2,None) 

elif data[1] == (1,4): 

data = ('BC',1,1) 

elif data[1] == (2,2): 

data = ('A',(1,1),1) 

 

# setting the parameters and returning the mutation type 

letter,rank,twist = data 

if not isinstance(letter, str): 

_mutation_type_error(data) 

if isinstance(rank, list): 

rank = tuple(rank) 

if isinstance(twist, list): 

twist = tuple(twist) 

return QuiverMutationType_Irreducible(letter,rank,twist) 

 

def _repr_(self): 

""" 

Return the string representation of ``self``. 

 

EXAMPLES:: 

 

sage: QuiverMutationType # indirect doctest 

QuiverMutationType 

""" 

return "QuiverMutationType" 

 

def samples(self, finite=None, affine=None, elliptic=None, 

mutation_finite=None): 

""" 

Return a sample of the available quiver mutations types. 

 

INPUT: 

 

- ``finite`` 

 

- ``affine`` 

 

- ``elliptic`` 

 

- ``mutation_finite`` 

 

All four input keywords default values are ``None``. If 

set to ``True`` or ``False``, only these samples are returned. 

 

EXAMPLES:: 

 

sage: QuiverMutationType.samples() 

[['A', 1], ['A', 5], ['B', 2], ['B', 5], ['C', 3], 

['C', 5], [ ['A', 1], ['A', 1] ], ['D', 5], ['E', 6], 

['E', 7], ['E', 8], ['F', 4], ['G', 2], 

['A', [1, 1], 1], ['A', [4, 5], 1], ['D', 4, 1], 

['BB', 5, 1], ['E', 6, [1, 1]], ['E', 7, [1, 1]], 

['R2', [1, 5]], ['R2', [3, 5]], ['E', 10], ['BE', 5], 

['GR', [3, 10]], ['T', [3, 3, 4]]] 

 

sage: QuiverMutationType.samples(finite=True) 

[['A', 1], ['A', 5], ['B', 2], ['B', 5], ['C', 3], 

['C', 5], [ ['A', 1], ['A', 1] ], ['D', 5], ['E', 6], 

['E', 7], ['E', 8], ['F', 4], ['G', 2]] 

 

sage: QuiverMutationType.samples(affine=True) 

[['A', [1, 1], 1], ['A', [4, 5], 1], ['D', 4, 1], ['BB', 5, 1]] 

 

sage: QuiverMutationType.samples(elliptic=True) 

[['E', 6, [1, 1]], ['E', 7, [1, 1]]] 

 

sage: QuiverMutationType.samples(mutation_finite=False) 

[['R2', [1, 5]], ['R2', [3, 5]], ['E', 10], ['BE', 5], 

['GR', [3, 10]], ['T', [3, 3, 4]]] 

""" 

result = self._samples() 

if finite is not None: 

result = [t for t in result if t.is_finite() == finite] 

if affine is not None: 

result = [t for t in result if t.is_affine() == affine] 

if elliptic is not None: 

result = [t for t in result if t.is_elliptic() == elliptic] 

if mutation_finite is not None: 

result = [t for t in result 

if t.is_mutation_finite() == mutation_finite] 

return result 

 

@cached_method 

def _samples(self): 

""" 

Return a list of sample of available Cartan types. 

 

EXAMPLES:: 

 

sage: X = QuiverMutationType._samples() 

""" 

finite_types = \ 

[QuiverMutationType(t) for t in [['A', 1], ['A', 5], ['B', 2], ['B', 5], 

['C', 3], ['C', 5], ['D', 2], ['D', 5], 

["E", 6], ["E", 7], ["E", 8], ["F", 4], 

["G", 2]]] 

affine_types = \ 

[QuiverMutationType(t) for t in [['A', [1,1], 1], ['A', [4,5], 1], ['D', 4, 1], ['BB', 5, 1]]] 

elliptic_types = \ 

[QuiverMutationType(t) for t in [['E', 6, [1,1]], ['E', 7, [1,1]]]] 

mutation_finite_types = \ 

[QuiverMutationType(t) for t in [['R2',(1,5)], ['R2',(3,5)]]] 

mutation_infinite_types = \ 

[QuiverMutationType(t) for t in [['E',10], ['BE',5], ['GR',(3,10)], ['T',(3,3,4)]]] 

 

return finite_types + affine_types + elliptic_types + mutation_finite_types + mutation_infinite_types 

 

QuiverMutationType = QuiverMutationTypeFactory() 

QuiverMutationType.__doc__ = \ 

r""" 

 

*Quiver mutation types* can be seen as a slight generalization of 

*generalized Cartan types*. 

 

Background on generalized Cartan types can be found at 

 

:wikipedia:`Generalized_Cartan_matrix` 

 

For the compendium on the cluster algebra and quiver package in Sage see [MS2011]_ 

 

A `B`-matrix is a skew-symmetrizable `( n \times n )`-matrix `M`. 

I.e., there exists an invertible diagonal matrix `D` such that `DM` is 

skew-symmetric. `M` can be encoded as a *quiver* by having a directed 

edge from vertex `i` to vertex `j` with label `(a,b)` if `a = M_{i,j} 

> 0` and `b = M_{j,i} < 0`. We consider quivers up to *mutation 

equivalence*. 

 

To a quiver mutation type we can associate a *generalized Cartan type* 

by sending `M` to the generalized Cartan matrix `C(M)` obtained by 

replacing all positive entries by their negatives and adding `2`'s on 

the main diagonal. 

 

``QuiverMutationType`` constructs a quiver mutation type object. For 

more detail on the possible different types, please see the 

compendium. 

 

INPUT: 

 

The input consists either of a quiver mutation type, or of a 

``letter`` (a string), a ``rank`` (one integer or a list/tuple of 

integers), and an optional ``twist`` (an integer or a list of 

integers). There are several different naming conventions for quiver 

mutation types. 

 

- Finite type -- ``letter`` is a Dynkin type (A-G), and ``rank`` is 

the rank. 

 

- Affine type -- there is more than one convention for naming affine 

types. 

 

* Kac's notation: ``letter`` is a Dynkin type, ``rank`` is the 

rank of the associated finite Dynkin diagram, and ``twist`` is the 

twist, which could be 1, 2, or 3. In the special case of affine 

type A, there is more than one quiver mutation type associated to 

the Cartan type. In this case only, ``rank`` is a pair of integers 

(i,j), giving the number of edges pointing clockwise and the number 

of edges pointing counter-clockwise. The total number of vertices 

is given by i+j in this case. 

 

* Naive notation: ``letter`` is one of 'BB', 'BC', 'BD', 'CC', 

'CD'. The name specifies the two ends of the diagram, which are 

joined by a path. The total number of vertices is given by 

``rank +1`` (to match the indexing people expect because these 

are affine types). In general, ``rank`` must be large enough 

for the picture to make sense, but we accept ``letter`` is 

``BC`` and ``rank=1``. 

 

* Macdonald notation: for the dual of an untwisted affine type 

(such as ['C', 6,1]), we accept a twist of -1 (i.e., 

['C',6,-1]). 

 

- Elliptic type -- ``letter`` is a Dynkin type, ``rank`` is the rank 

of the finite Dynkin diagram, and ``twist`` is a tuple of two 

integers. We follow Saito's notation. 

 

- Other shapes: 

 

* Rank 2: ``letter`` is 'R2', and ``rank`` is a pair of integers 

specifying the label on the unique edge. 

 

* Triangle: ``letter`` is ``TR``, and ``rank`` is the number of 

vertices along a side. 

 

* T: This defines a quiver shaped like a T. ``letter`` is 'T', 

and the ``rank`` is a triple, whose entries specify the number 

of vertices along each path from the branch point (counting the 

branch point). 

 

* Grassmannian: This defines the cluster algebra (without 

coefficients) corresponding to the cluster algebra with 

coefficients which is the co-ordinate ring of a Grassmannian. 

``letter`` is 'GR'. ``rank`` is a pair of integers (`k`, `n`) 

with 'k' < 'n' specifying the Grassmannian of `k`-planes in 

`n`-space. This defines a quiver given by a (k-1) x (n-k-1) 

grid where each square is cyclically oriented. 

 

* Exceptional mutation finite quivers: The two exceptional 

mutation finite quivers, found by Derksen-Owen, have ``letter`` 

as 'X' and ``rank`` 6 or 7, equal to the number of vertices. 

 

* AE, BE, CE, DE: Quivers are built of one end which looks like 

type (affine A), B, C, or D, and the other end which looks like 

type E (i.e., it consists of two antennae, one of length one, 

and one of length two). ``letter`` is 'AE', 'BE', 'CE', or 

'DE', and ``rank`` is the total number of vertices. Note that 

'AE' is of a slightly different form and requires ``rank`` to be 

a pair of integers (i,j) just as in the case of affine type A. 

See Exercise 4.3 in Kac's book Infinite Dimensional Lie Algebras 

for more details. 

 

* Infinite type E: It is also possible to obtain infinite-type E 

quivers by specifying ``letter`` as 'E' and ``rank`` as the 

number of vertices. 

 

REFERENCES: 

 

- A good reference for finite and affine Dynkin diagrams, including 

Kac's notation, is the :wikipedia:`Dynkin_diagram`. 

 

- A good reference for the skew-symmetrizable elliptic diagrams is 

"Cluster algebras of finite mutation type via unfolding" by 

A. Felikson, M. Shapiro, and P. Tumarkin, [FST2012]_. 

 

EXAMPLES: 

 

Finite types:: 

 

sage: QuiverMutationType('A',1) 

['A', 1] 

sage: QuiverMutationType('A',5) 

['A', 5] 

 

sage: QuiverMutationType('B',2) 

['B', 2] 

sage: QuiverMutationType('B',5) 

['B', 5] 

 

sage: QuiverMutationType('C',2) 

['B', 2] 

sage: QuiverMutationType('C',5) 

['C', 5] 

 

sage: QuiverMutationType('D',2) 

[ ['A', 1], ['A', 1] ] 

sage: QuiverMutationType('D',3) 

['A', 3] 

sage: QuiverMutationType('D',4) 

['D', 4] 

 

sage: QuiverMutationType('E',6) 

['E', 6] 

 

sage: QuiverMutationType('G',2) 

['G', 2] 

 

sage: QuiverMutationType('A',(1,0),1) 

['A', 1] 

 

sage: QuiverMutationType('A',(2,0),1) 

[ ['A', 1], ['A', 1] ] 

 

sage: QuiverMutationType('A',(7,0),1) 

['D', 7] 

 

Affine types:: 

 

sage: QuiverMutationType('A',(1,1),1) 

['A', [1, 1], 1] 

sage: QuiverMutationType('A',(2,4),1) 

['A', [2, 4], 1] 

 

sage: QuiverMutationType('BB',2,1) 

['BB', 2, 1] 

sage: QuiverMutationType('BB',4,1) 

['BB', 4, 1] 

 

sage: QuiverMutationType('CC',2,1) 

['CC', 2, 1] 

sage: QuiverMutationType('CC',4,1) 

['CC', 4, 1] 

 

sage: QuiverMutationType('BC',1,1) 

['BC', 1, 1] 

sage: QuiverMutationType('BC',5,1) 

['BC', 5, 1] 

 

sage: QuiverMutationType('BD',3,1) 

['BD', 3, 1] 

sage: QuiverMutationType('BD',5,1) 

['BD', 5, 1] 

 

sage: QuiverMutationType('CD',3,1) 

['CD', 3, 1] 

sage: QuiverMutationType('CD',5,1) 

['CD', 5, 1] 

 

sage: QuiverMutationType('D',4,1) 

['D', 4, 1] 

sage: QuiverMutationType('D',6,1) 

['D', 6, 1] 

 

sage: QuiverMutationType('E',6,1) 

['E', 6, 1] 

sage: QuiverMutationType('E',7,1) 

['E', 7, 1] 

sage: QuiverMutationType('E',8,1) 

['E', 8, 1] 

 

sage: QuiverMutationType('F',4,1) 

['F', 4, 1] 

sage: QuiverMutationType('F',4,-1) 

['F', 4, -1] 

 

sage: QuiverMutationType('G',2,1) 

['G', 2, 1] 

sage: QuiverMutationType('G',2,-1) 

['G', 2, -1] 

sage: QuiverMutationType('A',3,2) == QuiverMutationType('D',3,2) 

True 

 

Affine types using Kac's Notation:: 

 

sage: QuiverMutationType('A',1,1) 

['A', [1, 1], 1] 

sage: QuiverMutationType('B',5,1) 

['BD', 5, 1] 

sage: QuiverMutationType('C',5,1) 

['CC', 5, 1] 

sage: QuiverMutationType('A',2,2) 

['BC', 1, 1] 

sage: QuiverMutationType('A',7,2) 

['CD', 4, 1] 

sage: QuiverMutationType('A',8,2) 

['BC', 4, 1] 

sage: QuiverMutationType('D',6,2) 

['BB', 5, 1] 

sage: QuiverMutationType('E',6,2) 

['F', 4, -1] 

sage: QuiverMutationType('D',4,3) 

['G', 2, -1] 

 

Elliptic types:: 

 

sage: QuiverMutationType('E',6,[1,1]) 

['E', 6, [1, 1]] 

sage: QuiverMutationType('F',4,[2,1]) 

['F', 4, [1, 2]] 

sage: QuiverMutationType('G',2,[3,3]) 

['G', 2, [3, 3]] 

 

Mutation finite types: 

 

rank 2 cases:: 

 

sage: QuiverMutationType('R2',(1,1)) 

['A', 2] 

sage: QuiverMutationType('R2',(1,2)) 

['B', 2] 

sage: QuiverMutationType('R2',(1,3)) 

['G', 2] 

sage: QuiverMutationType('R2',(1,4)) 

['BC', 1, 1] 

sage: QuiverMutationType('R2',(1,5)) 

['R2', [1, 5]] 

sage: QuiverMutationType('R2',(2,2)) 

['A', [1, 1], 1] 

sage: QuiverMutationType('R2',(3,5)) 

['R2', [3, 5]] 

 

Exceptional Derksen-Owen quivers:: 

 

sage: QuiverMutationType('X',6) 

['X', 6] 

 

 

(Mainly) mutation infinite types: 

 

Infinite type E:: 

 

sage: QuiverMutationType('E',9) 

['E', 8, 1] 

sage: QuiverMutationType('E',10) 

['E', 10] 

sage: QuiverMutationType('E',12) 

['E', 12] 

 

sage: QuiverMutationType('AE',(2,3)) 

['AE', [2, 3]] 

sage: QuiverMutationType('BE',5) 

['BE', 5] 

sage: QuiverMutationType('CE',5) 

['CE', 5] 

sage: QuiverMutationType('DE',6) 

['DE', 6] 

 

Grassmannian types:: 

 

sage: QuiverMutationType('GR',(2,4)) 

['A', 1] 

sage: QuiverMutationType('GR',(2,6)) 

['A', 3] 

sage: QuiverMutationType('GR',(3,6)) 

['D', 4] 

sage: QuiverMutationType('GR',(3,7)) 

['E', 6] 

sage: QuiverMutationType('GR',(3,8)) 

['E', 8] 

sage: QuiverMutationType('GR',(3,10)) 

['GR', [3, 10]] 

 

Triangular types:: 

 

sage: QuiverMutationType('TR',2) 

['A', 3] 

sage: QuiverMutationType('TR',3) 

['D', 6] 

sage: QuiverMutationType('TR',4) 

['E', 8, [1, 1]] 

sage: QuiverMutationType('TR',5) 

['TR', 5] 

 

T types:: 

 

sage: QuiverMutationType('T',(1,1,1)) 

['A', 1] 

sage: QuiverMutationType('T',(1,1,4)) 

['A', 4] 

sage: QuiverMutationType('T',(1,4,4)) 

['A', 7] 

sage: QuiverMutationType('T',(2,2,2)) 

['D', 4] 

sage: QuiverMutationType('T',(2,2,4)) 

['D', 6] 

sage: QuiverMutationType('T',(2,3,3)) 

['E', 6] 

sage: QuiverMutationType('T',(2,3,4)) 

['E', 7] 

sage: QuiverMutationType('T',(2,3,5)) 

['E', 8] 

sage: QuiverMutationType('T',(2,3,6)) 

['E', 8, 1] 

sage: QuiverMutationType('T',(2,3,7)) 

['E', 10] 

sage: QuiverMutationType('T',(3,3,3)) 

['E', 6, 1] 

sage: QuiverMutationType('T',(3,3,4)) 

['T', [3, 3, 4]] 

 

Reducible types:: 

 

sage: QuiverMutationType(['A',3],['B',4]) 

[ ['A', 3], ['B', 4] ] 

""" 

 

 

class QuiverMutationType_abstract(UniqueRepresentation, SageObject): 

""" 

EXAMPLES:: 

 

sage: mut_type1 = QuiverMutationType('A',5) 

sage: mut_type2 = QuiverMutationType('A',5) 

sage: mut_type3 = QuiverMutationType('A',6) 

sage: mut_type1 == mut_type2 

True 

sage: mut_type1 == mut_type3 

False 

""" 

 

def _repr_(self): 

""" 

Return the string representation of ``self``. 

 

EXAMPLES:: 

 

sage: QuiverMutationType(['A',2]) # indirect doctest 

['A', 2] 

""" 

return self._description 

 

def plot(self, circular=False, directed=True): 

""" 

Return the plot of the underlying graph or digraph of ``self``. 

 

INPUT: 

 

- ``circular`` -- (default:``False``) if ``True``, the 

circular plot is chosen, otherwise >>spring<< is used. 

 

- ``directed`` -- (default: ``True``) if ``True``, the 

directed version is shown, otherwise the undirected. 

 

EXAMPLES:: 

 

sage: QMT = QuiverMutationType(['A',5]) 

sage: pl = QMT.plot() 

sage: pl = QMT.plot(circular=True) 

""" 

return self.standard_quiver().plot(circular=circular, directed=directed) 

 

def show(self, circular=False, directed=True): 

""" 

Show the plot of the underlying digraph of ``self``. 

 

INPUT: 

 

- ``circular`` -- (default:``False``) if ``True``, the 

circular plot is chosen, otherwise >>spring<< is used. 

 

- ``directed`` -- (default: ``True``) if ``True``, the 

directed version is shown, otherwise the undirected. 

 

TESTS:: 

 

sage: QMT = QuiverMutationType(['A',5]) 

sage: QMT.show() # long time 

""" 

self.plot( circular=circular, directed=directed ).show() 

 

def letter(self): 

""" 

Return the classification letter of ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType( ['A',5] ); mut_type 

['A', 5] 

sage: mut_type.letter() 

'A' 

 

sage: mut_type = QuiverMutationType( ['BC',5,1] ); mut_type 

['BC', 5, 1] 

sage: mut_type.letter() 

'BC' 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.letter() 

'A x B' 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]); mut_type 

[ ['A', 3], ['B', 3], ['X', 6] ] 

sage: mut_type.letter() 

'A x B x X' 

""" 

return self._letter 

 

def rank(self): 

""" 

Return the rank in the standard quiver of ``self``. 

 

The rank is the number of vertices. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType( ['A',5] ); mut_type 

['A', 5] 

sage: mut_type.rank() 

5 

 

sage: mut_type = QuiverMutationType( ['A',[4,5],1] ); mut_type 

['A', [4, 5], 1] 

sage: mut_type.rank() 

9 

 

sage: mut_type = QuiverMutationType( ['BC',5,1] ); mut_type 

['BC', 5, 1] 

sage: mut_type.rank() 

6 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.rank() 

6 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]); mut_type 

[ ['A', 3], ['B', 3], ['X', 6] ] 

sage: mut_type.rank() 

12 

""" 

return self._rank 

 

@cached_method 

def b_matrix(self): 

""" 

Return the B-matrix of the standard quiver of ``self``. 

 

The conventions for B-matrices agree with Fomin-Zelevinsky (up 

to a reordering of the simple roots). 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType( ['A',5] ); mut_type 

['A', 5] 

sage: mut_type.b_matrix() 

[ 0 1 0 0 0] 

[-1 0 -1 0 0] 

[ 0 1 0 1 0] 

[ 0 0 -1 0 -1] 

[ 0 0 0 1 0] 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.b_matrix() 

[ 0 1 0 0 0 0] 

[-1 0 -1 0 0 0] 

[ 0 1 0 0 0 0] 

[ 0 0 0 0 1 0] 

[ 0 0 0 -1 0 -1] 

[ 0 0 0 0 2 0] 

""" 

return _edge_list_to_matrix(self._digraph.edges(), list(range(self._rank)), []) 

 

@cached_method 

def standard_quiver(self): 

""" 

Return the standard quiver of ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType( ['A',5] ); mut_type 

['A', 5] 

sage: mut_type.standard_quiver() 

Quiver on 5 vertices of type ['A', 5] 

 

sage: mut_type = QuiverMutationType( ['A',[5,3],1] ); mut_type 

['A', [3, 5], 1] 

sage: mut_type.standard_quiver() 

Quiver on 8 vertices of type ['A', [3, 5], 1] 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.standard_quiver() 

Quiver on 6 vertices of type [ ['A', 3], ['B', 3] ] 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]); mut_type 

[ ['A', 3], ['B', 3], ['X', 6] ] 

sage: mut_type.standard_quiver() 

Quiver on 12 vertices of type [ ['A', 3], ['B', 3], ['X', 6] ] 

""" 

from .quiver import ClusterQuiver 

Q = ClusterQuiver(self._digraph) 

Q._mutation_type = self 

return Q 

 

@cached_method 

def cartan_matrix(self): 

""" 

Return the Cartan matrix of ``self``. 

 

Note that (up to a reordering of the simple roots) the convention for 

the definition of Cartan matrix, used here and elsewhere in Sage, 

agrees with the conventions of Kac, Fulton-Harris, and 

Fomin-Zelevinsky, but disagrees with the convention of Bourbaki. 

The `(i,j)` entry is `2(\\alpha_i,\\alpha_j)/(\\alpha_i,\\alpha_i)`. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType(['A',5]); mut_type 

['A', 5] 

sage: mut_type.cartan_matrix() 

[ 2 -1 0 0 0] 

[-1 2 -1 0 0] 

[ 0 -1 2 -1 0] 

[ 0 0 -1 2 -1] 

[ 0 0 0 -1 2] 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.cartan_matrix() 

[ 2 -1 0 0 0 0] 

[-1 2 -1 0 0 0] 

[ 0 -1 2 0 0 0] 

[ 0 0 0 2 -1 0] 

[ 0 0 0 -1 2 -1] 

[ 0 0 0 0 -2 2] 

""" 

# as soon as CartanMatrix is implemented we should use it here: 

# from sage.combinat.root_system.cartan_matrix import CartanMatrix 

cmat = copy(self.b_matrix()) 

for i,j in cmat.nonzero_positions(): 

a = cmat[i,j] 

if a > 0: cmat[i,j] = -a 

for i in range(self._rank): 

cmat[i,i] = 2 

# return CartanMatrix(cmat) 

return cmat 

 

def is_irreducible(self): 

""" 

Return ``True`` if ``self`` is irreducible. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_irreducible() 

True 

""" 

return self._info['irreducible'] 

 

def is_mutation_finite(self): 

""" 

Return ``True`` if ``self`` is of finite mutation type. 

 

This means that its mutation class has only finitely many 

different B-matrices. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['D',5,1]) 

sage: mt.is_mutation_finite() 

True 

""" 

return self._info['mutation_finite'] 

 

def is_simply_laced(self): 

""" 

Return ``True`` if ``self`` is simply laced. 

 

This means that the only arrows that appear in the quiver of 

``self`` are single unlabelled arrows. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_simply_laced() 

True 

 

sage: mt = QuiverMutationType(['B',2]) 

sage: mt.is_simply_laced() 

False 

 

sage: mt = QuiverMutationType(['A',(1,1),1]) 

sage: mt.is_simply_laced() 

False 

""" 

return self._info['simply_laced'] 

 

def is_skew_symmetric(self): 

""" 

Return ``True`` if the B-matrix of ``self`` is skew-symmetric. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_skew_symmetric() 

True 

 

sage: mt = QuiverMutationType(['B',2]) 

sage: mt.is_skew_symmetric() 

False 

 

sage: mt = QuiverMutationType(['A',(1,1),1]) 

sage: mt.is_skew_symmetric() 

True 

""" 

return self._info['skew_symmetric'] 

 

def is_finite(self): 

""" 

Return ``True`` if ``self`` is of finite type. 

 

This means that the cluster algebra associated to ``self`` has 

only a finite number of cluster variables. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_finite() 

True 

 

sage: mt = QuiverMutationType(['A',[4,2],1]) 

sage: mt.is_finite() 

False 

""" 

return self._info['finite'] 

 

def is_affine(self): 

""" 

Return ``True`` if ``self`` is of affine type. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_affine() 

False 

 

sage: mt = QuiverMutationType(['A',[4,2],1]) 

sage: mt.is_affine() 

True 

""" 

if self.is_irreducible(): 

return self._info['affine'] 

else: 

return False 

 

def is_elliptic(self): 

""" 

Return ``True`` if ``self`` is of elliptic type. 

 

EXAMPLES:: 

 

sage: mt = QuiverMutationType(['A',2]) 

sage: mt.is_elliptic() 

False 

 

sage: mt = QuiverMutationType(['E',6,[1,1]]) 

sage: mt.is_elliptic() 

True 

""" 

if self.is_irreducible(): 

return self._info['elliptic'] 

else: 

return False 

 

def properties(self): 

""" 

Print a scheme of all properties of ``self``. 

 

Most properties have natural definitions for either irreducible or 

reducible types. ``affine`` and ``elliptic`` are only defined for 

irreducible types. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType(['A',3]); mut_type 

['A', 3] 

sage: mut_type.properties() 

['A', 3] has rank 3 and the following properties: 

- irreducible: True 

- mutation finite: True 

- simply-laced: True 

- skew-symmetric: True 

- finite: True 

- affine: False 

- elliptic: False 

 

sage: mut_type = QuiverMutationType(['B',3]); mut_type 

['B', 3] 

sage: mut_type.properties() 

['B', 3] has rank 3 and the following properties: 

- irreducible: True 

- mutation finite: True 

- simply-laced: False 

- skew-symmetric: False 

- finite: True 

- affine: False 

- elliptic: False 

 

sage: mut_type = QuiverMutationType(['B',3,1]); mut_type 

['BD', 3, 1] 

sage: mut_type.properties() 

['BD', 3, 1] has rank 4 and the following properties: 

- irreducible: True 

- mutation finite: True 

- simply-laced: False 

- skew-symmetric: False 

- finite: False 

- affine: True 

- elliptic: False 

 

sage: mut_type = QuiverMutationType(['E',6,[1,1]]); mut_type 

['E', 6, [1, 1]] 

sage: mut_type.properties() 

['E', 6, [1, 1]] has rank 8 and the following properties: 

- irreducible: True 

- mutation finite: True 

- simply-laced: False 

- skew-symmetric: True 

- finite: False 

- affine: False 

- elliptic: True 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.properties() 

[ ['A', 3], ['B', 3] ] has rank 6 and the following properties: 

- irreducible: False 

- mutation finite: True 

- simply-laced: False 

- skew-symmetric: False 

- finite: True 

 

sage: mut_type = QuiverMutationType('GR',[4,9]); mut_type 

['GR', [4, 9]] 

sage: mut_type.properties() 

['GR', [4, 9]] has rank 12 and the following properties: 

- irreducible: True 

- mutation finite: False 

- simply-laced: True 

- skew-symmetric: True 

- finite: False 

- affine: False 

- elliptic: False 

""" 

txt = '{} has rank {} and the following properties:' 

print(txt.format(self, self.rank())) 

s = "\t- {} {}" 

print(s.format('irreducible: ', self.is_irreducible())) 

print(s.format('mutation finite: ', self.is_mutation_finite())) 

print(s.format('simply-laced: ', self.is_simply_laced())) 

print(s.format('skew-symmetric: ', self.is_skew_symmetric())) 

print(s.format('finite: ', self.is_finite())) 

if self.is_irreducible(): 

print(s.format('affine: ', self.is_affine())) 

print(s.format('elliptic: ', self.is_elliptic())) 

 

 

class QuiverMutationType_Irreducible(QuiverMutationType_abstract): 

""" 

The mutation type for a cluster algebra or a quiver. Should not be 

called directly, but through QuiverMutationType. 

""" 

def __init__(self, letter, rank, twist=None): 

""" 

Should not be called directly but through QuiverMutationType. 

 

INPUT: 

 

- ``letter`` -- the letter of the mutation type 

- ``rank`` -- the rank of the mutation type 

- ``twist`` -- the twist of the mutation type 

 

EXAMPLES:: 

 

sage: QuiverMutationType('A',5) 

['A', 5] 

 

sage: QuiverMutationType('A',[4,5],1) 

['A', [4, 5], 1] 

 

sage: QuiverMutationType('BB',5,1) 

['BB', 5, 1] 

 

sage: QuiverMutationType('X',6) 

['X', 6] 

""" 

# _rank and _bi_rank are initialized 

self._rank = None 

self._bi_rank = None 

 

# _graph and _digraph are initialized 

self._graph = Graph() 

self._digraph = DiGraph() 

 

# _info is initialized 

self._info = {} 

self._info['irreducible'] = True 

self._info['mutation_finite'] = False 

self._info['simply_laced'] = False 

self._info['skew_symmetric'] = False 

self._info['finite'] = False 

self._info['affine'] = False 

self._info['elliptic'] = False 

self._info['irreducible_components'] = False 

 

if isinstance(rank, tuple): 

rank = list(rank) 

if isinstance(twist, tuple): 

twist = list(twist) 

 

# _letter/twist is the input letter/twist 

self._letter = letter 

self._twist = twist 

 

data = [letter,rank,twist] 

 

# type A (finite and affine) 

if letter == 'A': 

if twist is None and rank in ZZ and rank > 0: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._info['finite'] = True 

elif twist==1 and isinstance(rank, list) and len(rank) == 2 and all( rank[i] in ZZ and rank[i] >= 0 for i in [0,1] ) and rank != [0,0]: 

if isinstance(rank, tuple): 

rank = list( rank ) 

data[1] = rank 

rank = sorted(rank) 

self._bi_rank = rank 

self._rank = sum( self._bi_rank ) 

self._info['mutation_finite'] = True 

if self._rank > 2: self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

if rank[0] > 0: 

self._info['affine'] = True 

elif rank[0] == 0: 

self._info['finite'] = True 

else: 

_mutation_type_error( data ) 

# types ['A',1] and ['A',[0,1],1] need to be treated on 

# itself (as there is no edge) 

if twist is None and self._rank == 1 or twist == 1 and self._rank == 1: 

self._graph.add_vertex( 0 ) 

# type ['A',[1,1],1] needs to be treated on itself as well 

# (as there is a double edge) 

elif twist == 1 and self._bi_rank[0] == 1 and self._bi_rank[1] == 1: 

self._graph.add_edge( 0,1,2 ) 

else: 

for i in range( self._rank - 1 ): 

self._graph.add_edge( i, i+1, 1 ) 

if twist == 1: 

self._digraph.add_edge( self._rank - 1, 0, 1 ) 

for i in range( self._rank - 1 ): 

if i < ( 2 * self._bi_rank[0] ) and i%2 == 0: 

self._digraph.add_edge( i+1, i, 1 ) 

else: 

self._digraph.add_edge( i, i+1, 1 ) 

 

# type B (finite) 

elif letter == 'B': 

if twist is None and rank in ZZ and rank > 1: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['finite'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if (rank % 2 == 0): 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

 

# type C (finite) 

elif letter == 'C': 

if twist is None and rank in ZZ and rank > 1: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['finite'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if (rank % 2 == 0): 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

 

# type BB (affine) 

elif letter == 'BB': 

if twist == 1 and rank in ZZ and rank > 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if rank % 2 == 0: 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

self._graph.add_edge( rank, 0 , (1,-2) ) 

 

# type CC (affine) 

elif letter == 'CC': 

if twist == 1 and rank in ZZ and rank > 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if rank % 2 == 0: 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

self._graph.add_edge( rank, 0 , (2,-1) ) 

 

# type BC (affine) 

elif letter == 'BC': 

if twist == 1 and rank in ZZ and rank >= 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

if rank == 1: 

self._graph.add_edge( 0,1,(1,-4) ) 

else: 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if (rank % 2 == 0): 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

if twist == 1: 

self._graph.add_edge( rank, 0 , (1,-2) ) 

 

# type BD (affine) 

elif letter == 'BD': 

if twist == 1 and rank in ZZ and rank > 2: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if (rank % 2 == 0): 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

if twist == 1: 

self._graph.add_edge( rank, 1 , 1 ) 

 

# type CD (affine) 

elif letter == 'CD': 

if twist == 1 and rank in ZZ and rank > 2: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

if (rank % 2 == 0): 

self._graph.add_edge( rank-2, rank-1, (2,-1) ) 

else: 

self._graph.add_edge( rank-2, rank-1, (1,-2) ) 

if twist == 1: 

self._graph.add_edge( rank, 1 , 1 ) 

 

# type D (finite and affine) 

elif letter == 'D': 

if rank in ZZ and rank > 3 and twist is None: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._info['finite'] = True 

elif twist == 1 and rank in ZZ and rank > 3: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._info['affine'] = True 

else: 

_mutation_type_error( data ) 

for i in range( rank - 2 ): 

self._graph.add_edge( i, i+1, 1 ) 

 

self._graph.add_edge( rank-3, rank-1, 1 ) 

if twist is not None: 

self._graph.add_edge( rank, 1 ,1 ) 

 

# type E (finite, affine and elliptic) 

elif letter == 'E': 

if rank in [6,7,8] and twist is None: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._info['finite'] = True 

if rank == 6: 

self._graph.add_edges( [ (0,1),(1,2),(2,3),(3,4),(2,5) ] ) 

elif rank == 7: 

self._graph.add_edges([(0, 1), (1, 2), (2, 3), 

(3, 4), (4, 5), (2, 6)]) 

elif rank == 8: 

self._graph.add_edges([(0, 1), (1, 2), (2, 3), 

(3, 4), (4, 5), (5, 6),(2, 7)]) 

elif rank in [6,7,8] and twist == 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._info['affine'] = True 

if rank == 6: 

self._graph.add_edges( [ (0,1),(1,2),(2,3),(3,4),(2,5),(5,6) ] ) 

elif rank == 7: 

self._graph.add_edges( [ (0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(3,7) ] ) 

elif rank == 8: 

self._graph.add_edges( [ (0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(2,8) ] ) 

elif rank in [6,7,8] and twist == [1,1]: 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['skew_symmetric'] = True 

self._info['elliptic'] = True 

if rank == 6: 

self._digraph.add_edges( [ (0,1,1),(1,2,1),(3,2,1),(3,4,1),(5,6,1),(6,7,1),(5,1,1),(2,5,2),(5,3,1),(6,2,1) ] ) 

elif rank == 7: 

self._digraph.add_edges( [ (1,0,1),(1,2,1),(2,3,1),(4,3,1),(4,5,1),(6,5,1),(7,8,1),(3,7,2),(7,2,1),(7,4,1),(8,3,1) ] ) 

elif rank == 8: 

self._digraph.add_edges( [ (0,1,1),(1,9,1),(3,9,1),(3,4,1),(2,8,1),(2,1,1),(9,2,2),(2,3,1),(8,9,1),(5,4,1),(5,6,1),(7,6,1) ] ) 

# type E (mutation infinite) 

elif rank > 9 and twist is None: 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

self._rank = rank 

for i in range(rank-2): 

self._graph.add_edge( i, i+1, 1 ) 

self._graph.add_edge( 2, rank-1 ) 

else: 

_mutation_type_error(data) 

 

# type AE (mutation infinite) 

elif letter == 'AE': 

if isinstance(rank, list) and len(rank) == 2 and all( rank[i] in ZZ and rank[i] > 0 for i in [0,1] ) and twist is None: 

if isinstance(rank, tuple): 

rank = list( rank ) 

data[1] = rank 

rank = sorted(rank) 

self._bi_rank = rank 

self._rank = sum( self._bi_rank ) + 1 

if self._rank > 3: self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

if self._bi_rank == [1,1]: 

self._graph.add_edges( [(0,1,2),(1,2,None)] ) 

else: 

self._digraph.add_edge( self._rank - 2, 0 ) 

for i in range(self._rank-2): 

if i < ( 2 * self._bi_rank[0] ) and i%2 == 0: 

self._digraph.add_edge(i+1,i) 

else: 

self._digraph.add_edge(i,i+1) 

self._digraph.add_edge(self._rank-2,self._rank-1) 

else: 

_mutation_type_error( data ) 

 

 

 

# type BE (mutation infinite) 

elif letter == 'BE': 

if rank >4 and twist is None: 

self._rank = rank 

for i in range(rank-3): 

self._graph.add_edge( i, i+1 ) 

self._graph.add_edge( 2, rank-1 ) 

if rank%2 == 0: 

self._graph.add_edge( rank-3,rank-2,(2,-1) ) 

else: 

self._graph.add_edge( rank-3,rank-2,(1,-2) ) 

else: 

_mutation_type_error( data ) 

 

# type CE (mutation infinite) 

elif letter == 'CE': 

if rank >4 and twist is None: 

self._rank = rank 

for i in range(rank-3): 

self._graph.add_edge( i, i+1 ) 

self._graph.add_edge( 2, rank-1 ) 

if rank%2 == 0: 

self._graph.add_edge( rank-3,rank-2,(1,-2) ) 

else: 

self._graph.add_edge( rank-3,rank-2,(2,-1) ) 

else: 

_mutation_type_error( data ) 

 

# type DE (mutation infinite) 

elif letter == 'DE': 

if rank >5 and twist is None: 

self._rank = rank 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

for i in range(rank-3): 

self._graph.add_edge( i, i+1 ) 

self._graph.add_edge( 2, rank-2 ) 

self._graph.add_edge( rank-4, rank-1 ) 

else: 

_mutation_type_error( data ) 

 

# type F (finite, affine, and elliptic) 

elif letter == 'F': 

if rank == 4 and twist is None: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['finite'] = True 

self._graph.add_edges( [ (0,1,None),(1,2,(2,-1)),(2,3,None) ] ) 

elif rank == 4 and twist == 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

self._graph.add_edges( [ (0,1,None), (1,2,None), 

(2,3,(1,-2)),(3,4,None) ] ) 

elif rank == 4 and twist == -1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

self._graph.add_edges( [ (0,1,None), (1,2,None), 

(2,3,(2,-1)),(3,4,None) ] ) 

elif rank == 4 and (twist == [1,2]): 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,None), 

(2,3,(2,-1)), (4,2,(1,-2)), 

(3,4,2), (4,5,None), (5,3,None) ]) 

elif rank == 4 and (twist == [2,1]): 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,None), 

(2,3,(1,-2)), (4,2,(2,-1)), 

(3,4,2), (4,5,None), (5,3,None) ]) 

elif rank == 4 and twist == [2,2]: 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,None), 

(3,1,None), (2,3,2), 

(4,2,(2,-1)), (3,4,(1,-2)), 

(5,4,None) ] ) 

elif rank == 4 and twist == [1,1]: 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,None), 

(3,1,None), (2,3,2), (4,2,(1,-2)), 

(3,4,(2,-1)), (5,4,None) ] ) 

else: 

_mutation_type_error( data ) 

 

# type G (finite, affine, and elliptic) 

elif letter == 'G': 

if rank == 2 and twist is None: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['finite'] = True 

self._graph.add_edges( [ (0,1,(1,-3)) ] ) 

elif rank == 2 and twist == -1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

self._graph.add_edges( [ (0,1,None),(1,2,(1,-3)) ] ) 

elif rank == 2 and twist == 1: 

self._rank = rank + 1 

self._info['mutation_finite'] = True 

self._info['affine'] = True 

self._graph.add_edges( [ (0,1,None),(1,2,(3,-1)) ] ) 

elif rank == 2 and (twist == [1,3]): 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,(3,-1)), 

(3,1,(1,-3)), (2,3,2)] ) 

elif rank == 2 and (twist == [3,1]): 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (0,1,None), (1,2,(1,-3)), 

(3,1,(3,-1)), (2,3,2)] ) 

elif rank == 2 and twist == [3,3]: 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (1,0,None), (0,2,2), (3,0,(3,-1)), 

(2,1,None), (2,3, (1,-3))]) 

elif rank == 2 and twist == [1,1]: 

self._rank = rank + 2 

self._info['mutation_finite'] = True 

self._info['elliptic'] = True 

self._digraph.add_edges( [ (1,0,None), (0,2,2), (3,0,(1,-3)), 

(2,1,None), (2,3,(3,-1)) ] ) 

else: 

_mutation_type_error( data ) 

 

# type GR (mutation infinite) 

elif letter == 'GR': 

if twist is None and isinstance(rank, list) and len(rank) == 2 and all( rank[i] in ZZ and rank[i] > 0 for i in [0,1] ) and rank[1] - 1 > rank[0] > 1: 

gr_rank = (rank[0]-1,rank[1]-rank[0]-1) 

self._rank = prod(gr_rank) 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

a,b = gr_rank 

for i in range(a): 

for j in range(b): 

if i < a-1: 

if (i+j) % 2 == 0: 

self._digraph.add_edge(i*b+j,(i+1)*b+j) 

else: 

self._digraph.add_edge((i+1)*b+j,i*b+j) 

if j < b-1: 

if (i+j) % 2 == 0: 

self._digraph.add_edge(i*b+j+1,i*b+j) 

else: 

self._digraph.add_edge(i*b+j,i*b+j+1) 

else: 

_mutation_type_error( data ) 

 

# type R2 (rank 2 finite mutation types) 

elif letter == 'R2': 

if twist is None and isinstance(rank, list) and len(rank) == 2 and all( rank[i] in ZZ and rank[i] > 0 for i in [0,1] ): 

rank = sorted(rank) 

b,c = rank 

self._rank = 2 

if b == c: self._info['skew_symmetric'] = True 

self._graph.add_edge(0,1,(b,-c)) 

else: 

_mutation_type_error( data ) 

 

# type T 

elif letter == 'T': 

if twist is None and isinstance(rank, list) and len(rank) == 3 and all( rank[i] in ZZ and rank[i] > 0 for i in [0,1,2] ): 

if isinstance(rank, tuple): 

rank = list( rank ) 

data[1] = rank 

rank = sorted( rank ) 

self._rank = sum( rank ) - 2 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

r,p,q = rank 

for i in range(q-1): 

if i == 0: 

self._graph.add_edge(0,1) 

self._graph.add_edge(0,r) 

self._graph.add_edge(0,r+p-1) 

else: 

if i < r-1: 

self._graph.add_edge(i,i+1) 

if i < p-1: 

self._graph.add_edge(i+r-1,i+r) 

self._graph.add_edge(i+r+p-2,i+r+p-1) 

else: 

_mutation_type_error( data ) 

 

# type TR (mutation infinite if rank > 2) 

elif letter == 'TR': 

# type ['TR',1] needs to be treated on itself (as there is no edge) 

if twist is None and rank == 1: 

self._graph.add_vertex( 0 ) 

elif twist is None and rank > 1: 

self._rank = rank*(rank+1)//2 

self._info['simply_laced'] = True 

self._info['skew_symmetric'] = True 

level = 0 

while level < rank: 

nr = rank*level-sum(range(level)) 

for i in range(nr,nr+rank-level-1): 

self._digraph.add_edge(i,i+1) 

self._digraph.add_edge(i+rank-level,i) 

self._digraph.add_edge(i+1,i+rank-level) 

level += 1 

else: 

_mutation_type_error( data ) 

 

# type X 

elif letter == 'X': 

if rank in [6,7] and twist is None: 

self._rank = rank 

self._info['mutation_finite'] = True 

self._info['skew_symmetric'] = True 

self._digraph.add_edges( [ (0,1,2),(1,2,None),(2,0,None), 

(2,3,None),(3,4,2),(4,2,None), 

(2,5,None) ] ) 

if rank == 7: 

self._digraph.add_edges( [ (5,6,2),(6,2,None) ] ) 

else: 

_mutation_type_error( data ) 

 

# otherwise, an error is raised 

else: 

_mutation_type_error( data ) 

 

# in the bipartite case, the digraph is constructed from the graph 

if not self._digraph: 

if self._graph.is_bipartite(): 

self._digraph = _bipartite_graph_to_digraph( self._graph ) 

else: 

raise ValueError('The QuiverMutationType does not have ' 

'a Coxeter diagram.') 

 

# in the other cases, the graph is constructed from the digraph 

if not self._graph: 

self._graph = self._digraph.to_undirected() 

 

# _description is as for CartanType 

if twist: self._description = str( [letter,rank,twist] ) 

else: self._description = str( [letter,rank] ) 

 

def irreducible_components( self ): 

""" 

Return a list of all irreducible components of ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType('A',3); mut_type 

['A', 3] 

sage: mut_type.irreducible_components() 

(['A', 3],) 

""" 

return tuple([self]) 

 

@cached_method 

def class_size(self): 

""" 

If it is known, the size of the mutation class of all quivers 

which are mutation equivalent to the standard quiver of 

``self`` (up to isomorphism) is returned. 

 

Otherwise, ``NotImplemented`` is returned. 

 

Formula for finite type A is taken from Torkildsen - Counting 

cluster-tilted algebras of type `A_n`. 

Formulas for affine type A and finite type D are taken from Bastian, 

Prellberg, Rubey, Stump - Counting the number of elements in the 

mutation classes of `\widetilde A_n` quivers. 

Formulas for finite and affine types B and C are 

proven but not yet published. 

Conjectural formulas for several other non-simply-laced affine types 

are implemented. 

Exceptional Types (finite, affine, and elliptic) E, F, G, and X are 

hardcoded. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType( ['A',5] ); mut_type 

['A', 5] 

sage: mut_type.class_size() 

19 

 

sage: mut_type = QuiverMutationType( ['A',[10,3],1] ); mut_type 

['A', [3, 10], 1] 

sage: mut_type.class_size() 

142120 

 

sage: mut_type = QuiverMutationType( ['B',6] ); mut_type 

['B', 6] 

sage: mut_type.class_size() 

132 

 

sage: mut_type = QuiverMutationType( ['BD',6,1] ); mut_type 

['BD', 6, 1] 

sage: mut_type.class_size() 

Warning: This method uses a formula which has not been proved correct. 

504 

 

Check that :trac:`14048` is fixed:: 

 

sage: mut_type = QuiverMutationType( ['F',4,(2,1)] ) 

sage: mut_type.class_size() 

90 

""" 

if not self.is_mutation_finite(): 

return infinity 

 

# type A (finite and affine) 

if self._letter == 'A': 

# the formula is taken from Torkildsen - Counting 

# cluster-tilted algebras of type A 

if self.is_finite(): 

n = self._rank 

a = binomial( 2*(n+1), n+1 ) // (n+2) 

if n % 2 == 1: 

a += binomial( n+1, (n+1)//2 ) 

if n % 3 == 0: 

a += 2 * binomial( 2*n//3, n//3 ) 

return a // (n+3) 

# the formula is taken from Bastian, Prellberg, Rubey, Stump 

elif self.is_affine(): 

i,j = self._bi_rank 

i = ZZ(i) 

j = ZZ(j) 

n = i+j 

f = Euler_Phi() 

if i == j: 

return ( binomial( 2*i,i ) + 

sum( f(k) * binomial(2*i//k,i//k)**2 

for k in [k for k in i.divisors() 

if k in j.divisors()] ) // n ) // 4 

else: 

return sum( f(k) * binomial(2*i//k,i//k) * 

binomial(2*j//k,j//k) 

for k in [k for k in i.divisors() 

if k in j.divisors()] ) // ( 2 * n ) 

 

# types B and C (finite and affine) 

elif self._letter in ['B', 'C']: 

# this formula is proven but nowhere published correctness 

# is clear enough that I don't think a warning is needed 

if self.is_finite(): 

n = self._rank 

return binomial(2 * n, n) // (n + 1) 

 

elif self._letter in ['BB','CC']: 

# these two formulas are not yet proven 

print(Warning("Warning: This method uses a formula " 

"which has not been proved correct.")) 

if self.is_affine(): 

if self._twist == 1: 

n = self._rank - 1 

if n%2==1: 

return binomial( 2*n-1, n-1 ) 

else: 

return binomial( 2*n-1, n-1 ) + binomial( n-1, n//2 -1 ) 

 

# type BC (affine) 

elif self._letter == 'BC': 

# this formula is not yet proven 

print(Warning("Warning: This method uses a formula " 

"which has not been proved correct.")) 

if self.is_affine(): 

if self._twist == 1: 

n = self._rank - 1 

return binomial( 2*n, n ) 

 

# types BD and CD (affine) 

elif self._letter in ['BD','CD']: 

# this formula is not yet proven 

print(Warning("Warning: This method uses a formula " 

"which has not been proved correct.")) 

if self.is_affine(): 

if self._twist == 1: 

n = self._rank - 2 

return 2*binomial( 2*n, n ) 

 

# type D (finite and affine) 

elif self._letter == 'D': 

# the formula is taken from Bastian, Prellberg, Rubey, Stump 

if self.is_finite(): 

if self._rank == 4: 

return 6 

else: 

f = Euler_Phi() 

n = ZZ(self._rank) 

return sum( f( n//k ) * binomial( 2*k, k ) 

for k in n.divisors() ) // (2*n) 

# this formula is not yet proven 

elif self.is_affine(): 

n = self._rank - 3 

if n == 2: 

return 9 

else: 

print(Warning ("Warning: This method uses a formula " 

"which has not been proved correct.")) 

if n%2==1: 

return 2*binomial(2*n,n) 

else: 

return 2*binomial(2*n,n) + binomial(n, n//2) 

 

# the exceptional types are hard-coded 

# type E (finite, affine and elliptic) 

elif self._letter == 'E': 

if self.is_finite(): 

if self._rank == 6: 

return 67 

elif self._rank == 7: 

return 416 

elif self._rank == 8: 

return 1574 

elif self.is_affine(): 

if self._rank == 7: 

return 132 

elif self._rank == 8: 

return 1080 

elif self._rank == 9: 

return 7560 

elif self.is_elliptic(): 

if self._rank == 8: 

return 49 

elif self._rank == 9: 

return 506 

elif self._rank == 10: 

return 5739 

 

# type F 

elif self._letter == 'F': 

if self.is_finite(): 

return 15 

elif self.is_affine(): 

return 60 

elif self.is_elliptic(): 

if self._twist == [1,2]: 

return 90 

if self._twist == [1,1] or self._twist == [2,2]: 

return 35 

 

# type G 

elif self._letter == 'G': 

if self.is_finite(): 

return 2 

elif self.is_affine(): 

return 6 

elif self.is_elliptic(): 

if self._twist == [1,3]: 

return 7 

if self._twist == [1,1] or self._twist == [3,3]: 

return 2 

 

# type X 

elif self._letter == 'X': 

if self._rank == 6: 

return 5 

elif self._rank == 7: 

return 2 

 

# otherwise the size is returned to be unknown 

else: 

print("Size unknown") 

return NotImplemented 

 

def dual(self): 

""" 

Return the QuiverMutationType which is dual to ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType('A',5); mut_type 

['A', 5] 

sage: mut_type.dual() 

['A', 5] 

 

sage: mut_type = QuiverMutationType('B',5); mut_type 

['B', 5] 

sage: mut_type.dual() 

['C', 5] 

sage: mut_type.dual().dual() 

['B', 5] 

sage: mut_type.dual().dual() == mut_type 

True 

""" 

letter = self.letter() 

# the self-dual cases 

if letter != 'BC' and letter[0] in ['B','C']: 

if letter == 'BB': letter = 'CC' 

elif letter == 'CC': letter = 'BB' 

elif letter[0] == 'B': letter = 'C' + letter[1:] 

elif letter[0] == 'C': letter = 'B' + letter[1:] 

rank = self._rank 

if self.is_affine(): 

rank -= 1 

twist = self._twist 

return QuiverMutationType(letter,rank,twist) 

# the cases F and G have non-trivial duality in some cases 

elif letter in ['F','G']: 

if self.is_finite(): return self 

elif self.is_affine(): 

rank = self._rank - 1 

twist = - self._twist 

elif self.is_elliptic(): 

twist = self._twist 

rank = self._rank - 2 

if letter == 'F': 

if self._twist == [2,2]: 

twist == [1,1] 

if self._twist == [1,1]: 

twist == [2,2] 

if letter == 'G': 

if self._twist == [3,3]: 

twist = [1,1] 

elif self._twist == [1,1]: 

twist = [3,3] 

else: rank = self._rank 

return QuiverMutationType(letter,rank,twist) 

else: 

return self 

 

 

class QuiverMutationType_Reducible(QuiverMutationType_abstract): 

""" 

The mutation type for a cluster algebra or a quiver. Should not be 

called directly, but through QuiverMutationType. Inherits from 

QuiverMutationType_abstract. 

""" 

def __init__(self, *args): 

""" 

Should not be called directly, but through QuiverMutationType. 

 

INPUT: 

 

- ``data`` -- a list each of whose entries is a 

QuiverMutationType_Irreducible 

 

EXAMPLES:: 

 

sage: QuiverMutationType(['A',4],['B',6]) 

[ ['A', 4], ['B', 6] ] 

""" 

data = args 

if len(data) < 2 or not all( isinstance(comp, QuiverMutationType_Irreducible) for comp in data ): 

return _mutation_type_error(data) 

 

# _info is initialized 

self._info = {} 

self._info['irreducible'] = False 

self._info['mutation_finite'] = all(comp.is_mutation_finite() 

for comp in data) 

self._info['simply_laced'] = all(comp.is_simply_laced() 

for comp in data) 

self._info['skew_symmetric'] = all(comp.is_skew_symmetric() 

for comp in data) 

self._info['finite'] = all(comp.is_finite() for comp in data) 

self._info['irreducible_components'] = copy(data) 

 

# letter and rank are initialized 

self._letter = '' 

self._rank = 0 

 

# graph and digraph are initialized 

self._graph = Graph() 

self._digraph = DiGraph() 

 

for comp in data: 

if self._letter: 

self._letter += ' x ' 

self._letter += comp._letter 

self._rank += comp._rank 

self._graph = self._graph.disjoint_union(comp._graph, 

labels='integers') 

self._digraph = self._digraph.disjoint_union(comp._digraph, 

labels='integers') 

self._graph.name('') 

self._digraph.name('') 

 

# _description is as for CartanType 

self._description = "[ " 

comps = self.irreducible_components() 

for i in range(len(comps)): 

if i > 0: self._description += ", " 

self._description += comps[i]._description 

self._description += " ]" 

 

def irreducible_components( self ): 

""" 

Return a list of all irreducible components of ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType('A',3); mut_type 

['A', 3] 

sage: mut_type.irreducible_components() 

(['A', 3],) 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.irreducible_components() 

(['A', 3], ['B', 3]) 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]) 

sage: mut_type 

[ ['A', 3], ['B', 3], ['X', 6] ] 

sage: mut_type.irreducible_components() 

(['A', 3], ['B', 3], ['X', 6]) 

""" 

return self._info['irreducible_components'] 

 

@cached_method 

def class_size(self): 

""" 

If it is known, the size of the mutation class of all quivers 

which are mutation equivalent to the standard quiver of 

``self`` (up to isomorphism) is returned. 

 

Otherwise, ``NotImplemented`` is returned. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type 

[ ['A', 3], ['B', 3] ] 

sage: mut_type.class_size() 

20 

 

sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]) 

sage: mut_type 

[ ['A', 3], ['B', 3], ['X', 6] ] 

sage: mut_type.class_size() 

100 

""" 

if not self.is_mutation_finite(): 

return infinity 

else: 

components = [] 

multiplicities = [] 

for x in self.irreducible_components(): 

if components.count(x) == 0: 

components.append(x) 

multiplicities.append(1) 

else: 

y = components.index(x) 

multiplicities[y] = multiplicities[y]+1 

 

sizes = [ x.class_size() for x in components ] 

if NotImplemented in sizes: 

print("Size unknown") 

return NotImplemented 

else: 

return prod( [binomial(sizes[i]+multiplicities[i]-1, 

multiplicities[i] ) for i in range (0,len(sizes))]) 

 

def dual(self): 

""" 

Return the QuiverMutationType which is dual to ``self``. 

 

EXAMPLES:: 

 

sage: mut_type = QuiverMutationType(['A',5],['B',6],['C',5],['D',4]); mut_type 

[ ['A', 5], ['B', 6], ['C', 5], ['D', 4] ] 

sage: mut_type.dual() 

[ ['A', 5], ['C', 6], ['B', 5], ['D', 4] ] 

""" 

comps = self.irreducible_components() 

return QuiverMutationType( [comp.dual() for comp in comps ] ) 

 

 

def _construct_classical_mutation_classes(n): 

r""" 

Return a dict with keys being tuples representing regular 

QuiverMutationTypes of the given rank, and with values being lists 

or sets containing all mutation equivalent quivers as dig6 data. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _construct_classical_mutation_classes 

sage: rank_2_classes = _construct_classical_mutation_classes(2) # long time 

sage: for mut_class in sorted(rank_2_classes.keys(),key=str): # long time 

....: print("{} {}".format(mut_class, rank_2_classes[mut_class])) 

('A', (1, 1), 1) [('AO', (((0, 1), (2, -2)),))] 

('A', 2) [('AO', ())] 

('B', 2) [('AO', (((0, 1), (1, -2)),)), ('AO', (((0, 1), (2, -1)),))] 

('BC', 1, 1) [('AO', (((0, 1), (1, -4)),)), 

('AO', (((0, 1), (4, -1)),))] 

""" 

from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver 

data = {} 

 

# finite A 

data[ ('A',n) ] = ClusterQuiver(['A',n]).mutation_class(data_type='dig6') 

# affine A 

for j in range(1, n//2+1): 

data[ ('A',(n-j,j),1) ] = ClusterQuiver(['A',[n-j,j],1]).mutation_class(data_type='dig6') 

# finite B 

if n > 1: 

data[ ('B',n) ] = ClusterQuiver(['B',n]).mutation_class(data_type='dig6') 

# affine B 

if n > 2: 

data[ ('BB',n-1,1) ] = ClusterQuiver(['BB',n-1,1]).mutation_class(data_type='dig6') 

# finite C 

if n > 2: 

data[ ('C',n) ] = ClusterQuiver(['C',n]).mutation_class(data_type='dig6') 

# affine C 

if n > 1: 

data[ ('BC',n-1,1) ] = ClusterQuiver(['BC',n-1,1]).mutation_class(data_type='dig6') 

# affine CC 

if n > 2: 

data[ ('CC',n-1,1) ] = ClusterQuiver(['CC',n-1,1]).mutation_class(data_type='dig6') 

# affine BD 

if n > 3: 

data[ ('BD',n-1,1) ] = ClusterQuiver(['BD',n-1,1]).mutation_class(data_type='dig6') 

# affine CD 

if n > 3: 

data[ ('CD',n-1,1) ] = ClusterQuiver(['CD',n-1,1]).mutation_class(data_type='dig6') 

# finite D 

if n > 3: 

data[ ('D',n) ] = ClusterQuiver(['D',n]).mutation_class(data_type='dig6') 

# affine D 

if n > 4: 

data[ ('D',n-1,1) ] = ClusterQuiver(['D',n-1,1]).mutation_class(data_type='dig6') 

 

return data 

 

 

def _construct_exceptional_mutation_classes(n): 

r""" 

Return a dict with keys being tuples representing exceptional 

QuiverMutationTypes of the given rank, and with values being lists 

or sets containing all mutation equivalent quivers as dig6 data. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _construct_exceptional_mutation_classes 

sage: rank_3_exceptional = _construct_exceptional_mutation_classes(3) # long time 

sage: for mut_class in sorted(rank_3_exceptional.keys(), key=str): # long time 

....: print("{} {}".format(mut_class, rank_3_exceptional[mut_class])) 

('G', 2, -1) [('BH?', (((1, 2), (1, -3)),)), 

('BGO', (((2, 1), (3, -1)),)), ('BW?', (((0, 1), (3, -1)),)), 

('BP?', (((0, 1), (1, -3)),)), 

('BP_', (((0, 1), (1, -3)), ((2, 0), (3, -1)))), 

('BP_', (((0, 1), (3, -1)), ((1, 2), (1, -3)), ((2, 0), (2, -2))))] 

('G', 2, 1) [('BH?', (((1, 2), (3, -1)),)), 

('BGO', (((2, 1), (1, -3)),)), ('BW?', (((0, 1), (1, -3)),)), 

('BP?', (((0, 1), (3, -1)),)), 

('BKO', (((1, 0), (3, -1)), ((2, 1), (1, -3)))), 

('BP_', (((0, 1), (2, -2)), ((1, 2), (1, -3)), ((2, 0), (3, -1))))] 

""" 

from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver 

data = {} 

# finite E 

if n in [6,7,8]: 

data[ ('E',n) ] = ClusterQuiver(['E',n]).mutation_class(data_type='dig6') 

# affine E 

if n in [7,8,9]: 

data[ ('E',n-1,1) ] = ClusterQuiver(['E',n-1,1]).mutation_class(data_type='dig6') 

# elliptic E 

if n in [8,9,10]: 

data[ ('E',n-2,(1,1)) ] = ClusterQuiver(['E',n-2,[1,1]]).mutation_class(data_type='dig6') 

# finite F 

if n == 4: 

data[ ('F',4) ] = ClusterQuiver(['F',4]).mutation_class(data_type='dig6') 

# affine F 

if n == 5: 

data[ ('F',4,1) ] = ClusterQuiver(['F',4,1]).mutation_class(data_type='dig6') 

data[ ('F',4,-1) ] = ClusterQuiver(['F',4,-1]).mutation_class(data_type='dig6') 

# finite G 

if n == 2: 

data[ ('G',2) ] = ClusterQuiver(['G',2]).mutation_class(data_type='dig6') 

# affine G 

if n == 3: 

data[ ('G',2,1) ] = ClusterQuiver(['G',2,1]).mutation_class(data_type='dig6') 

data[ ('G',2,-1) ] = ClusterQuiver(['G',2,-1]).mutation_class(data_type='dig6') 

# elliptic G 

if n == 4: 

data[ ('G',2,(1,3)) ] = ClusterQuiver(['G',2,(1,3)]).mutation_class(data_type='dig6') 

data[ ('G',2,(1,1)) ] = ClusterQuiver(['G',2,(1,1)]).mutation_class(data_type='dig6') 

data[ ('G',2,(3,3)) ] = ClusterQuiver(['G',2,(3,3)]).mutation_class(data_type='dig6') 

# X 

if n in [6,7]: 

data[ ('X',n) ] = ClusterQuiver(['X',n]).mutation_class(data_type='dig6') 

# elliptic F 

if n == 6: 

data[ ('F',4,(1,2)) ] = ClusterQuiver(['F',4,(1,2)]).mutation_class(data_type='dig6') 

data[ ('F',4,(1,1)) ] = ClusterQuiver(['F',4,(1,1)]).mutation_class(data_type='dig6') 

data[ ('F',4,(2,2)) ] = ClusterQuiver(['F',4,(2,2)]).mutation_class(data_type='dig6') 

 

return data 

 

 

def _save_data_dig6(n, types='ClassicalExceptional', verbose=False): 

""" 

Save all exceptional mutation classes as dig6 data into the file ``exc_classes_n.dig6`` in the folder ``DOT_SAGE``. 

 

TESTS:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import save_quiver_data 

sage: save_quiver_data(2) # indirect doctest 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', 1)] 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] 

 

sage: save_quiver_data(2,up_to=False) # indirect doctest 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] 

 

sage: save_quiver_data(2,up_to=False, types='Classical') # indirect doctest 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1)] 

 

sage: save_quiver_data(2,up_to=False, types='Exceptional') # indirect doctest 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('G', 2)] 

 

sage: save_quiver_data(2,up_to=False, verbose=False) # indirect doctest 

""" 

import os.path 

from six.moves import cPickle 

data = {} 

possible_types = ['Classical', 'ClassicalExceptional', 'Exceptional'] 

if types not in possible_types: 

raise ValueError('The third input must be either ClassicalExceptional' 

' (default), Classical, or Exceptional.') 

 

if types in possible_types[:2]: 

data.update(_construct_classical_mutation_classes(n)) 

if types in possible_types[1:]: 

data.update(_construct_exceptional_mutation_classes(n)) 

 

from sage.env import DOT_SAGE 

from sage.misc.misc import sage_makedirs 

types_path = os.path.join(DOT_SAGE, 'cluster_algebra_quiver') 

types_file = os.path.join(types_path,'mutation_classes_%s.dig6'%n) 

sage_makedirs(types_path) 

from sage.misc.temporary_file import atomic_write 

with atomic_write(types_file) as f: 

cPickle.dump(data, f) 

if verbose: 

keys = sorted(data.keys(),key=str) 

print("\nThe following types are saved to file", types_file,"and will now be used to determine quiver mutation types:") 

print(keys) 

 

 

def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True): 

r""" 

Save mutation classes of certain quivers of ranks up to and equal 

to ``n`` or equal to ``n`` to 

``DOT_SAGE/cluster_algebra_quiver/mutation_classes_n.dig6``. 

 

This data will then be used to determine quiver mutation types. 

 

INPUT: 

 

- ``n``: the rank (or the upper limit on the rank) of the mutation 

classes that are being saved. 

 

- ``up_to`` -- (default:``True``) if ``True``, saves data for 

ranks smaller than or equal to ``n``. If ``False``, saves data 

for rank exactly ``n``. 

 

- ``types`` -- (default:'ClassicalExceptional') if all, saves data 

for both exceptional mutation-finite quivers and for classical 

quiver. The input 'Exceptional' or 'Classical' is also allowed 

to save only part of this data. 

 

TESTS:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import save_quiver_data 

sage: save_quiver_data(2) 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', 1)] 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] 

 

sage: save_quiver_data(2,up_to=False) 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] 

 

sage: save_quiver_data(2,up_to=False, types='Classical') 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1)] 

 

sage: save_quiver_data(2,up_to=False, types='Exceptional') 

<BLANKLINE> 

The following types are saved to file ... and will now be used to determine quiver mutation types: 

[('G', 2)] 

 

sage: save_quiver_data(2,up_to=False, verbose=False) 

""" 

from sage.combinat.cluster_algebra_quiver.mutation_type import load_data 

if up_to is True: 

ranks = range(1,n+1) 

elif up_to is False: 

ranks = [n] 

for i in ranks: 

_save_data_dig6(i,types=types,verbose=verbose) 

# we finally clear the load_data 

load_data.clear_cache() 

 

 

def _bipartite_graph_to_digraph(g): 

""" 

Return a digraph obtained from a bipartite graph g by choosing one 

set of the bipartition to be the set of sinks and the other to be the 

set of sources. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type \ 

import _bipartite_graph_to_digraph 

sage: G = Graph([(1,2)]) 

sage: _bipartite_graph_to_digraph(G) 

Digraph on 2 vertices 

""" 

if not g.is_bipartite(): 

raise ValueError('The input graph is not bipartite.') 

 

order = g.bipartite_sets() 

dg = DiGraph() 

for edge in g.edges(): 

if edge[0] in order[0]: 

dg.add_edge( edge[0],edge[1],edge[2] ) 

else: 

dg.add_edge( edge[1],edge[0],edge[2] ) 

for vert in g.vertices(): 

if vert not in dg.vertices(): 

dg.add_vertex(vert) 

return dg 

 

 

def _is_mutation_type(data): 

""" 

Return ``True`` if ``data`` is a QuiverMutationType. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _is_mutation_type 

sage: _is_mutation_type ( [ 'A', 2 ] ) 

True 

sage: _is_mutation_type ( [ 'P', 1 ] ) 

False 

""" 

try: 

QuiverMutationType(data) 

return True 

except Exception: 

return False 

 

def _mutation_type_error(data): 

""" 

Output an error message because data which is not a valid quiver mutation 

type has been passed to QuiverMutationType. 

 

EXAMPLES:: 

 

sage: QuiverMutationType( 'Christian', 'Stump' ) # indirect doctest 

Traceback (most recent call last): 

... 

ValueError: ['Christian', 'Stump'] is not a valid quiver mutation type 

Finite types have the form [ '?', n ] for type ? and rank n 

Affine type A has the form [ 'A', [ i, j ], 1 ] for rank i+j 

Affine type ? has the form [ '?', k, \pm 1 ] for rank k+1 

Elliptic type ? has the form [ '?', k, [i, j] ] (1 <= i,j <= 3) for rank k+2 

For correct syntax in other types, please consult the documentation. 

""" 

if data[2] is None: 

del data[2] 

return_str = str(data) + ' is not a valid quiver mutation type' 

return_str += '\n Finite types have the form [ \'?\', n ] for type ? and rank n' 

return_str += '\n Affine type A has the form [ \'A\', [ i, j ], 1 ] for rank i+j' 

return_str += '\n Affine type ? has the form [ \'?\', k, \pm 1 ] for rank k+1' 

return_str += '\n Elliptic type ? has the form [ \'?\', k, [i, j] ] (1 <= i,j <= 3) for rank k+2' 

return_str += '\n For correct syntax in other types, please consult the documentation.' 

 

raise ValueError(return_str) 

 

 

def _edge_list_to_matrix(edges, nlist, mlist): 

r""" 

Return the matrix obtained from the edge list of a quiver. 

 

INPUT: 

 

- ``edges`` -- the list of edges 

- ``nlist`` -- the list of mutable vertices of the quiver 

- ``mlist`` -- the list of frozen vertices of the quiver 

 

OUTPUT: 

 

An `(n+m) \times n` matrix corresponding to the edge-list. 

 

EXAMPLES:: 

 

sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _edge_list_to_matrix 

sage: G = QuiverMutationType(['A',2])._digraph 

sage: _edge_list_to_matrix(G.edges(), [0,1], []) 

[ 0 1] 

[-1 0] 

 

sage: G2 = DiGraph([('a', 'b', 1)]) 

sage: _edge_list_to_matrix(G2.edges(), ['a', 'b'], []) 

[ 0 1] 

[-1 0] 

 

sage: G3 = DiGraph([('a', 'b', 1), ('b', 'c', 1)]) 

sage: _edge_list_to_matrix(G3.edges(), ['a', 'b'], ['c']) 

[ 0 1] 

[-1 0] 

[ 0 -1] 

""" 

n = len(nlist); m = len(mlist) 

nmlist = nlist + mlist 

M = matrix(ZZ, n + m, n, sparse=True) 

for edge in edges: 

if edge[2] is None: 

edge = (edge[0], edge[1], (1, -1)) 

elif edge[2] in ZZ: 

edge = (edge[0], edge[1], (edge[2], -edge[2])) 

v1, v2, (a, b) = edge 

if v1 in nlist: 

M[nmlist.index(v2), nmlist.index(v1)] = b 

if v2 in nlist: 

M[nmlist.index(v1), nmlist.index(v2)] = a 

return M