MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / pathSet

Method pathSet

src/class195/Code09_Jail1.java:188–218  ·  view source on GitHub ↗
(int x, int y, int prisoner)

Source from the content-addressed store, hash-verified

186 }
187
188 public static void pathSet(int x, int y, int prisoner) {
189 if (dep[x] < dep[y]) {
190 int tmp = x;
191 x = y;
192 y = tmp;
193 }
194 addEdge2(startTag[y], prisoner);
195 addEdge2(prisoner, endTag[y]);
196 for (int p = MAXP - 1; p >= 0; p--) {
197 if (dep[stjump[x][p]] >= dep[y]) {
198 addEdge2(stout[x][p], prisoner);
199 addEdge2(prisoner, stin[x][p]);
200 x = stjump[x][p];
201 }
202 }
203 if (x == y) {
204 return;
205 }
206 for (int p = MAXP - 1; p >= 0; p--) {
207 if (stjump[x][p] != stjump[y][p]) {
208 addEdge2(stout[x][p], prisoner);
209 addEdge2(stout[y][p], prisoner);
210 addEdge2(prisoner, stin[x][p]);
211 addEdge2(prisoner, stin[y][p]);
212 x = stjump[x][p];
213 y = stjump[y][p];
214 }
215 }
216 addEdge2(stout[x][0], prisoner);
217 addEdge2(prisoner, stin[x][0]);
218 }
219
220 public static void link(int x, int y) {
221 int prisoner = ++cntt;

Callers 1

linkMethod · 0.95

Calls 1

addEdge2Method · 0.95

Tested by

no test coverage detected