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

Method dfs3

src/class185/Code05_OpenStore1.java:121–154  ·  view source on GitHub ↗
(int cur, int father, int distance)

Source from the content-addressed store, hash-verified

119 }
120
121 public static void dfs3(int cur, int father, int distance) {
122 stacksize = 0;
123 push(cur, father, distance, 0, -1);
124 while (stacksize > 0) {
125 pop();
126 if (e == -1) {
127 fa[u] = f;
128 dep[u] = dep[f] + 1;
129 dist[u] = a;
130 siz[u] = 1;
131 e = head[u];
132 } else {
133 e = nxt[e];
134 }
135 if (e != 0) {
136 push(u, f, a, 0, e);
137 int v = to[e];
138 int w = weight[e];
139 if (v != f) {
140 push(v, u, a + w, 0, -1);
141 }
142 } else {
143 for (int ei = head[u]; ei > 0; ei = nxt[ei]) {
144 int v = to[ei];
145 if (v != f) {
146 siz[u] += siz[v];
147 if (son[u] == 0 || siz[son[u]] < siz[v]) {
148 son[u] = v;
149 }
150 }
151 }
152 }
153 }
154 }
155
156 public static void dfs4(int cur, int tag) {
157 stacksize = 0;

Callers 1

mainMethod · 0.95

Calls 2

pushMethod · 0.95
popMethod · 0.95

Tested by

no test coverage detected