You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/24 07:18:41 UTC

[GitHub] [flink] zhuzhurk commented on a change in pull request #13205: [FLINK-17330[runtime] Merge cyclic dependent pipelined regions into one region

zhuzhurk commented on a change in pull request #13205:
URL: https://github.com/apache/flink/pull/13205#discussion_r475388935



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/flip1/StronglyConnectedComponentsComputeUtils.java
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.runtime.executiongraph.failover.flip1;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Utility for computing strongly connected components.
+ *
+ * <p>The computation is an implementation of Tarjan's algorithm.
+ *
+ * <p>Ref: https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm.
+ */
+public final class StronglyConnectedComponentsComputeUtils {
+
+	static Set<Set<Integer>> computeStronglyConnectedComponents(final int numVertex, final List<List<Integer>> outEdges) {
+		final Set<Set<Integer>> stronglyConnectedComponents = new HashSet<>();
+
+		final int[] vertexIndices = new int[numVertex];
+		Arrays.fill(vertexIndices, -1);
+
+		final int[] vertexLowLinks = new int[numVertex];
+		final Deque<Integer> stack = new ArrayDeque<>(numVertex);

Review comment:
       renamed it as `visitingStack`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org