Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.free_module.CombinatorialFreeModuleElement
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebraElement_generic
Create a combinatorial module element. This should never be called directly, but only through the parent combinatorial free module’s __call__() method.
TESTS:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: B = F.basis()
sage: f = B['a'] + 3*B['c']; f
B['a'] + 3*B['c']
sage: f == loads(dumps(f))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_ak(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_bk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.combinatorial_algebra.CombinatorialAlgebra
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: s = PartitionAlgebra_sk(QQ, 3, 1)
sage: s == loads(dumps(s))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_pk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_prk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_rk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_sk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Bases: sage.combinat.partition_algebra.PartitionAlgebra_generic
EXAMPLES:
sage: from sage.combinat.partition_algebra import *
sage: p = PartitionAlgebra_tk(QQ, 3, 1)
sage: p == loads(dumps(p))
True
Returns the combinatorial class of set partitions of type A_k.
EXAMPLES:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: A3.last() #random
{{-1}, {-2}, {3}, {1}, {-3}, {2}}
sage: A3.random_element() #random
{{1, 3, -3, -1}, {2, -2}}
sage: A3.cardinality()
203
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5.cardinality()
52
sage: A2p5.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: A2p5.last() #random
{{-1}, {-2}, {2}, {3, -3}, {1}}
sage: A2p5.random_element() #random
{{-1}, {-2}, {3, -3}, {1, 2}}
Bases: sage.combinat.set_partition.SetPartitions_set
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
Bases: sage.combinat.combinat.CombinatorialClass
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsAk(1.5).cardinality()
5
sage: SetPartitionsAk(2.5).cardinality()
52
sage: SetPartitionsAk(3.5).cardinality()
877
Returns the combinatorial class of set partitions of type B_k. These are the set partitions where every block has size 2.
EXAMPLES:
sage: B3 = SetPartitionsBk(3); B3
Set partitions of {1, ..., 3, -1, ..., -3} with block size 2
sage: B3.first() #random
{{2, -2}, {1, -3}, {3, -1}}
sage: B3.last() #random
{{1, 2}, {3, -2}, {-3, -1}}
sage: B3.random_element() #random
{{2, -1}, {1, -3}, {3, -2}}
sage: B3.cardinality()
15
sage: B2p5 = SetPartitionsBk(2.5); B2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block and with block size 2
sage: B2p5.first() #random
{{2, -1}, {3, -3}, {1, -2}}
sage: B2p5.last() #random
{{1, 2}, {3, -3}, {-1, -2}}
sage: B2p5.random_element() #random
{{2, -2}, {3, -3}, {1, -1}}
sage: B2p5.cardinality()
3
Bases: sage.combinat.partition_algebra.SetPartitionsAk_k
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
Returns the number of set partitions in B_k where k is an integer. This is given by (2k)!! = (2k-1)*(2k-3)*...*5*3*1.
EXAMPLES:
sage: SetPartitionsBk(3).cardinality()
15
sage: SetPartitionsBk(2).cardinality()
3
sage: SetPartitionsBk(1).cardinality()
1
sage: SetPartitionsBk(4).cardinality()
105
sage: SetPartitionsBk(5).cardinality()
945
Bases: sage.combinat.partition_algebra.SetPartitionsAkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: B3p5 = SetPartitionsBk(3.5)
sage: B3p5.cardinality()
15
Returns the combinatorial class of set partitions of type I_k. These are set partitions with a propagating number of less than k. Note that the identity set partition {{1, -1}, ..., {k, -k}} is not in I_k.
EXAMPLES:
sage: I3 = SetPartitionsIk(3); I3
Set partitions of {1, ..., 3, -1, ..., -3} with propagating number < 3
sage: I3.cardinality()
197
sage: I3.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: I3.last() #random
{{-1}, {-2}, {3}, {1}, {-3}, {2}}
sage: I3.random_element() #random
{{-1}, {-3, -2}, {2, 3}, {1}}
sage: I2p5 = SetPartitionsIk(2.5); I2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block and propagating number < 3
sage: I2p5.cardinality()
50
sage: I2p5.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: I2p5.last() #random
{{-1}, {-2}, {2}, {3, -3}, {1}}
sage: I2p5.random_element() #random
{{-1}, {-2}, {1, 3, -3}, {2}}
Bases: sage.combinat.partition_algebra.SetPartitionsAk_k
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
TESTS:
sage: SetPartitionsIk(2).cardinality()
13
Bases: sage.combinat.partition_algebra.SetPartitionsAkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsIk(1.5).cardinality()
4
sage: SetPartitionsIk(2.5).cardinality()
50
sage: SetPartitionsIk(3.5).cardinality()
871
Bases: sage.combinat.partition_algebra.SetPartitionsRk_k
TESTS:
sage: PR3 = SetPartitionsPRk(3); PR3
Set partitions of {1, ..., 3, -1, ..., -3} with at most 1 positive and negative entry in each block and that are planar
sage: PR3 == loads(dumps(PR3))
True
TESTS:
sage: SetPartitionsPRk(2).cardinality()
6
sage: SetPartitionsPRk(3).cardinality()
20
sage: SetPartitionsPRk(4).cardinality()
70
sage: SetPartitionsPRk(5).cardinality()
252
Bases: sage.combinat.partition_algebra.SetPartitionsRkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsPRk(2.5).cardinality()
6
sage: SetPartitionsPRk(3.5).cardinality()
20
sage: SetPartitionsPRk(4.5).cardinality()
70
Returns the combinatorial class of set partitions of type P_k. These are the planar set partitions.
EXAMPLES:
sage: P3 = SetPartitionsPk(3); P3
Set partitions of {1, ..., 3, -1, ..., -3} that are planar
sage: P3.cardinality()
132
sage: P3.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: P3.last() #random
{{-1}, {-2}, {3}, {1}, {-3}, {2}}
sage: P3.random_element() #random
{{1, 2, -1}, {-3}, {3, -2}}
sage: P2p5 = SetPartitionsPk(2.5); P2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block and that are planar
sage: P2p5.cardinality()
42
sage: P2p5.first() #random
{{1, 2, 3, -1, -3, -2}}
sage: P2p5.last() #random
{{-1}, {-2}, {2}, {3, -3}, {1}}
sage: P2p5.random_element() #random
{{1, 2, 3, -3}, {-1, -2}}
Bases: sage.combinat.partition_algebra.SetPartitionsAk_k
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
TESTS:
sage: SetPartitionsPk(2).cardinality()
14
sage: SetPartitionsPk(3).cardinality()
132
sage: SetPartitionsPk(4).cardinality()
1430
Bases: sage.combinat.partition_algebra.SetPartitionsAkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsPk(2.5).cardinality()
42
sage: SetPartitionsPk(1.5).cardinality()
5
Bases: sage.combinat.partition_algebra.SetPartitionsAk_k
TESTS:
sage: R3 = SetPartitionsRk(3); R3
Set partitions of {1, ..., 3, -1, ..., -3} with at most 1 positive and negative entry in each block
sage: R3 == loads(dumps(R3))
True
TESTS:
sage: SetPartitionsRk(2).cardinality()
7
sage: SetPartitionsRk(3).cardinality()
34
sage: SetPartitionsRk(4).cardinality()
209
sage: SetPartitionsRk(5).cardinality()
1546
Bases: sage.combinat.partition_algebra.SetPartitionsAkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsRk(2.5).cardinality()
7
sage: SetPartitionsRk(3.5).cardinality()
34
sage: SetPartitionsRk(4.5).cardinality()
209
Returns the combinatorial class of set partitions of type S_k. There is a bijection between these set partitions and the permutations of 1, ..., k.
EXAMPLES:
sage: S3 = SetPartitionsSk(3); S3
Set partitions of {1, ..., 3, -1, ..., -3} with propagating number 3
sage: S3.cardinality()
6
sage: S3.list() #random
[{{2, -2}, {3, -3}, {1, -1}},
{{1, -1}, {2, -3}, {3, -2}},
{{2, -1}, {3, -3}, {1, -2}},
{{1, -2}, {2, -3}, {3, -1}},
{{1, -3}, {2, -1}, {3, -2}},
{{1, -3}, {2, -2}, {3, -1}}]
sage: S3.first() #random
{{2, -2}, {3, -3}, {1, -1}}
sage: S3.last() #random
{{1, -3}, {2, -2}, {3, -1}}
sage: S3.random_element() #random
{{1, -3}, {2, -1}, {3, -2}}
sage: S3p5 = SetPartitionsSk(3.5); S3p5
Set partitions of {1, ..., 4, -1, ..., -4} with 4 and -4 in the same block and propagating number 4
sage: S3p5.cardinality()
6
sage: S3p5.list() #random
[{{2, -2}, {3, -3}, {1, -1}, {4, -4}},
{{2, -3}, {1, -1}, {4, -4}, {3, -2}},
{{2, -1}, {3, -3}, {1, -2}, {4, -4}},
{{2, -3}, {1, -2}, {4, -4}, {3, -1}},
{{1, -3}, {2, -1}, {4, -4}, {3, -2}},
{{1, -3}, {2, -2}, {4, -4}, {3, -1}}]
sage: S3p5.first() #random
{{2, -2}, {3, -3}, {1, -1}, {4, -4}}
sage: S3p5.last() #random
{{1, -3}, {2, -2}, {4, -4}, {3, -1}}
sage: S3p5.random_element() #random
{{1, -3}, {2, -2}, {4, -4}, {3, -1}}
Bases: sage.combinat.partition_algebra.SetPartitionsAk_k
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
Returns k!.
TESTS:
sage: SetPartitionsSk(2).cardinality()
2
sage: SetPartitionsSk(3).cardinality()
6
sage: SetPartitionsSk(4).cardinality()
24
sage: SetPartitionsSk(5).cardinality()
120
Bases: sage.combinat.partition_algebra.SetPartitionsAkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsSk(2.5).cardinality()
2
sage: SetPartitionsSk(3.5).cardinality()
6
sage: SetPartitionsSk(4.5).cardinality()
24
sage: ks = [2.5, 3.5, 4.5, 5.5]
sage: sks = [SetPartitionsSk(k) for k in ks]
sage: all([ sk.cardinality() == len(sk.list()) for sk in sks])
True
Returns the combinatorial class of set partitions of type T_k. These are planar set partitions where every block is of size 2.
EXAMPLES:
sage: T3 = SetPartitionsTk(3); T3
Set partitions of {1, ..., 3, -1, ..., -3} with block size 2 and that are planar
sage: T3.cardinality()
5
sage: T3.first() #random
{{1, -3}, {2, 3}, {-1, -2}}
sage: T3.last() #random
{{1, 2}, {3, -1}, {-3, -2}}
sage: T3.random_element() #random
{{1, -3}, {2, 3}, {-1, -2}}
sage: T2p5 = SetPartitionsTk(2.5); T2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block and with block size 2 and that are planar
sage: T2p5.cardinality()
2
sage: T2p5.first() #random
{{2, -2}, {3, -3}, {1, -1}}
sage: T2p5.last() #random
{{1, 2}, {3, -3}, {-1, -2}}
Bases: sage.combinat.partition_algebra.SetPartitionsBk_k
TESTS:
sage: A3 = SetPartitionsAk(3); A3
Set partitions of {1, ..., 3, -1, ..., -3}
sage: A3 == loads(dumps(A3))
True
TESTS:
sage: SetPartitionsTk(2).cardinality()
2
sage: SetPartitionsTk(3).cardinality()
5
sage: SetPartitionsTk(4).cardinality()
14
sage: SetPartitionsTk(5).cardinality()
42
Bases: sage.combinat.partition_algebra.SetPartitionsBkhalf_k
TESTS:
sage: A2p5 = SetPartitionsAk(2.5); A2p5
Set partitions of {1, ..., 3, -1, ..., -3} with 3 and -3 in the same block
sage: A2p5 == loads(dumps(A2p5))
True
TESTS:
sage: SetPartitionsTk(2.5).cardinality()
2
sage: SetPartitionsTk(3.5).cardinality()
5
sage: SetPartitionsTk(4.5).cardinality()
14
EXAMPLES:
sage: from sage.combinat.partition_algebra import create_set_partition_function
sage: create_set_partition_function('A', 3)
Set partitions of {1, ..., 3, -1, ..., -3}
Returns the identity set partition 1, -1, ..., k, -k
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: pa.identity(2)
{{2, -2}, {1, -1}}
Returns True if the diagram corresponding to the set partition is planar; otherwise, it returns False.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: pa.is_planar( pa.to_set_partition([[1,-2],[2,-1]]))
False
sage: pa.is_planar( pa.to_set_partition([[1,-1],[2,-2]]))
True
Returns a graph consisting of the graphs of set partitions sp1 and sp2 along with edges joining the bottom row (negative numbers) of sp1 to the top row (positive numbers) of sp2.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: sp1 = pa.to_set_partition([[1,-2],[2,-1]])
sage: sp2 = pa.to_set_partition([[1,-2],[2,-1]])
sage: g = pa.pair_to_graph( sp1, sp2 ); g
Graph on 8 vertices
sage: g.vertices() #random
[(1, 2), (-1, 1), (-2, 2), (-1, 2), (-2, 1), (2, 1), (2, 2), (1, 1)]
sage: g.edges() #random
[((1, 2), (-1, 1), None),
((1, 2), (-2, 2), None),
((-1, 1), (2, 1), None),
((-1, 2), (2, 2), None),
((-2, 1), (1, 1), None),
((-2, 1), (2, 2), None)]
Returns the propagating number of the set partition sp. The propagating number is the number of blocks with both a positive and negative number.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: sp1 = pa.to_set_partition([[1,-2],[2,-1]])
sage: sp2 = pa.to_set_partition([[1,2],[-2,-1]])
sage: pa.propagating_number(sp1)
2
sage: pa.propagating_number(sp2)
0
Returns a tuple consisting of the composition of the set partitions sp1 and sp2 and the number of components removed from the middle rows of the graph.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: sp1 = pa.to_set_partition([[1,-2],[2,-1]])
sage: sp2 = pa.to_set_partition([[1,-2],[2,-1]])
sage: pa.set_partition_composition(sp1, sp2) == (pa.identity(2), 0)
True
Returns a graph representing the set partition sp.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: g = pa.to_graph( pa.to_set_partition([[1,-2],[2,-1]])); g
Graph on 4 vertices
sage: g.vertices() #random
[1, 2, -2, -1]
sage: g.edges() #random
[(1, -2, None), (2, -1, None)]
Coverts a list of a list of numbers to a set partitions. Each list of numbers in the outer list specifies the numbers contained in one of the blocks in the set partition.
If k is specified, then the set partition will be a set partition of 1, ..., k, -1, ..., -k. Otherwise, k will default to the minimum number needed to contain all of the specified numbers.
EXAMPLES:
sage: import sage.combinat.partition_algebra as pa
sage: pa.to_set_partition([[1,-1],[2,-2]]) == pa.identity(2)
True