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

Method tarjan2

src/class191/Code01_CutEdge1.java:95–129  ·  view source on GitHub ↗
(int node, int pree)

Source from the content-addressed store, hash-verified

93 // 如果status == 1,表示u遍历到儿子v,然后发现dfn[v] != 0
94 // 对应递归版for循环中的else分支
95 public static void tarjan2(int node, int pree) {
96 stacksize = 0;
97 push(node, pree, -1, -1);
98 int v;
99 while (stacksize > 0) {
100 pop();
101 if (status == -1) {
102 dfn[u] = low[u] = ++cntd;
103 e = head[u];
104 } else {
105 v = to[e];
106 if (status == 0) {
107 low[u] = Math.min(low[u], low[v]);
108 if (low[v] > dfn[u]) {
109 cutEdge[e >> 1] = true;
110 }
111 } else {
112 low[u] = Math.min(low[u], dfn[v]);
113 }
114 e = nxt[e];
115 }
116 if ((e ^ 1) == preEdge) {
117 e = nxt[e];
118 }
119 if (e != 0) {
120 v = to[e];
121 if (dfn[v] == 0) {
122 push(u, preEdge, 0, e);
123 push(v, e, -1, -1);
124 } else {
125 push(u, preEdge, 1, e);
126 }
127 }
128 }
129 }
130
131 public static void main(String[] args) throws Exception {
132 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