-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPermutation.java
164 lines (143 loc) · 3.76 KB
/
Permutation.java
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
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Ben Rexin <benjamin.rexin@haw-hamburg.de>
* @author Patrick Detlefsen <patrick.detlefsen@haw-hamburg.de>
* @author Till Theis
* @author Raimund Wege
* @author Andreas Wimmer
* @author Sebastian Krome
* @author Daniel
* @author Fenja Harbke
* @author Felix Schmidt
* @author Berthold Wiblishauser
* @version 0.2
* @since 2011-10-12
*/
public interface Permutation extends Iterable<Integer> {
/**
* Return the image of a value.
*
* @param inverseImage the inverse image
* @return the image or -1 if is a NoPermution
* @throws IllegalArgumentException unless 1 <= inverseImage <= permutationClass()
*/
int getPermElement(int inverseImage) throws IllegalArgumentException;
/**
* Return the permutation that is built of the n-th cycle of the original permutation and its class.
*
* @param index the cycle index (beginning at 1)
* @return the cycle Permutation or NoPermution
*/
Cycle cycle(int index);
/**
* All the cycles of the image.
*
* @return the cycles
*/
List<Cycle> allCycles();
/**
*
* @return all cycle-states as permutation
*/
List<Cycle> allCyclesAsPermutaion();
/**
* All the fixed points.
*
* @return the fixed points
*/
Set<Integer> fixedPoints();
/**
* The inverse permutation.
*
* @return the inverse permutation
*/
Permutation inverse();
/**
* Compose this permutation with the other one.
*
* @param other the Permutation to compose with
* @return the composition or NoPermutation if exception
*/
Permutation compose(Permutation other);
/**
* The permutation in mathematical notation.
*
* @return the mathematical notation
* @see #toCycleNotationString()
*/
public String toString();
/**
* The mathematical cycle notation ({@link http://en.wikipedia.org/wiki/Cycle_notation})
*
* @return the cycle notation
*/
String toCycleNotationString();
/**
* The permutation class (i.e. the number of its images, aka Sn-class of
* Permutation)
*
* @return the permutation class
*/
int permutationClass();
/**
* Test for structural equality.
* Two permutations are considered equal if they describe the same
* relation.
*
* @return boolean
*/
public boolean equals(Object other);
/**
* Calculates the Order of a given Permutation
* @return int
*/
int order();
/**
* Calculates the Potentenz of the Permutation
* @return Permutation
*/
Permutation permPower(int n);
/**
* CycleType as String
* @return String
*/
public String toCycleTypeString();
/**
* CylceType as Map
* @return Map<Integer,Integer>
*/
public Map<Integer,Integer> cycleType();
/**
* cycle notation will be formed into transposition notation.
*
* @return the transposition notation
*/
public List<Transposition> toTranspositions();
/**
* transposition notation as String
*
* @return the transposition notation
*/
public String toTranspositionString();
/**
* make the signature of transposition
*
* @return int
*/
public int sign();
/**
* Returns the n-th permutation in lexical order (rank) of a given permutation-class
*
* @return Permutation
* @see http://bytes.com/topic/java/insights/632857-permutations-b
*/
public Permutation unRank(int rank);
/**
* Returns the rank of a given Permutation or -1, if the permutation is invalid
*
* @return int
*/
public int rank();
}