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

Method tarjan2

src/class191/Code05_EBCC1.java:102–147  ·  view source on GitHub ↗
(int node, int pree)

Source from the content-addressed store, hash-verified

100
101 // 迭代版
102 public static void tarjan2(int node, int pree) {
103 stacksize = 0;
104 push(node, pree, -1, -1);
105 int v;
106 while (stacksize > 0) {
107 pop();
108 if (status == -1) {
109 dfn[u] = low[u] = ++cntd;
110 sta[++top] = u;
111 e = head[u];
112 } else {
113 v = to[e];
114 if (status == 0) {
115 low[u] = Math.min(low[u], low[v]);
116 } else {
117 low[u] = Math.min(low[u], dfn[v]);
118 }
119 e = nxt[e];
120 }
121 if ((e ^ 1) == preEdge) {
122 e = nxt[e];
123 }
124 if (e != 0) {
125 v = to[e];
126 if (dfn[v] == 0) {
127 push(u, preEdge, 0, e);
128 push(v, e, -1, -1);
129 } else {
130 push(u, preEdge, 1, e);
131 }
132 } else {
133 if (dfn[u] == low[u]) {
134 ebccCnt++;
135 ebccSiz[ebccCnt] = 0;
136 ebccl[ebccCnt] = idx + 1;
137 int pop;
138 do {
139 pop = sta[top--];
140 ebccSiz[ebccCnt]++;
141 ebccArr[++idx] = pop;
142 } while (pop != u);
143 ebccr[ebccCnt] = idx;
144 }
145 }
146 }
147 }
148
149 public static void main(String[] args) throws Exception {
150 FastReader in = new FastReader(System.in);

Callers 1

mainMethod · 0.95

Calls 2

pushMethod · 0.95
popMethod · 0.95

Tested by

no test coverage detected