<commit_before>/*
 * 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.graph.partition.centric.example;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.partition.centric.PCGraph;
import org.apache.flink.graph.partition.centric.PCVertex;
import org.apache.flink.graph.partition.centric.PartitionMessagingFunction;
import org.apache.flink.graph.partition.centric.PartitionUpdateFunction;

import java.util.*;

/**
 * Example for partition centric iteration
 */
public class PartitionCentricConnectedComponent {

    public static void main(String[] args) throws Exception {
        Collection<Vertex<Integer, Integer>> vertices = Arrays.asList(
                new Vertex<>(1, 1),
                new Vertex<>(2, 2),
                new Vertex<>(3, 3),
                new Vertex<>(4, 4),
                new Vertex<>(5, 5),
                new Vertex<>(6, 6),
                new Vertex<>(7, 7),
                new Vertex<>(8, 8),
                new Vertex<>(9, 9)
        );
        Collection<Edge<Integer, Integer>> edges = Arrays.asList(
                new Edge<>(1, 2, 1),
                new Edge<>(2, 1, 1),
                new Edge<>(2, 3, 1),
                new Edge<>(3, 2, 1),
                new Edge<>(3, 1, 1),
                new Edge<>(1, 3, 1),
                new Edge<>(3, 4, 1),
                new Edge<>(4, 3, 1),
                new Edge<>(5, 6, 1),
                new Edge<>(6, 5, 1),
                new Edge<>(6, 7, 1),
                new Edge<>(7, 6, 1)
        );

        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();

        Graph<Integer, Integer, Integer> graph = Graph.fromCollection(vertices, edges, environment);

        PCGraph<Integer, Integer, Integer> pcGraph = PCGraph.fromGraph(graph);

        PCGraph<Integer, Integer, Integer> result =
                pcGraph.runPartitionCentricIteration(new CCPartitionUpdateFunction(), new CCPartitionMessagingFunction(), 10);
<commit_msg>Disable sysout logging for the example.<commit_after>/*
 * 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.graph.partition.centric.example;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.partition.centric.PCGraph;
import org.apache.flink.graph.partition.centric.PCVertex;
import org.apache.flink.graph.partition.centric.PartitionMessagingFunction;
import org.apache.flink.graph.partition.centric.PartitionUpdateFunction;

import java.util.*;

/**
 * Example for partition centric iteration
 */
public class PartitionCentricConnectedComponent {

    public static void main(String[] args) throws Exception {
        Collection<Vertex<Integer, Integer>> vertices = Arrays.asList(
                new Vertex<>(1, 1),
                new Vertex<>(2, 2),
                new Vertex<>(3, 3),
                new Vertex<>(4, 4),
                new Vertex<>(5, 5),
                new Vertex<>(6, 6),
                new Vertex<>(7, 7),
                new Vertex<>(8, 8),
                new Vertex<>(9, 9)
        );
        Collection<Edge<Integer, Integer>> edges = Arrays.asList(
                new Edge<>(1, 2, 1),
                new Edge<>(2, 1, 1),
                new Edge<>(2, 3, 1),
                new Edge<>(3, 2, 1),
                new Edge<>(3, 1, 1),
                new Edge<>(1, 3, 1),
                new Edge<>(3, 4, 1),
                new Edge<>(4, 3, 1),
                new Edge<>(5, 6, 1),
                new Edge<>(6, 5, 1),
                new Edge<>(6, 7, 1),
                new Edge<>(7, 6, 1)
        );

        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();

        environment.getConfig().disableSysoutLogging();

        Graph<Integer, Integer, Integer> graph = Graph.fromCollection(vertices, edges, environment);

        PCGraph<Integer, Integer, Integer> pcGraph = PCGraph.fromGraph(graph);

        PCGraph<Integer, Integer, Integer> result =
                pcGraph.runPartitionCentricIteration(new CCPartitionUpdateFunction(), new CCPartitionMessagingFunction(), 10);

{'fraction_non_alphanumeric': 0.11138654767806974, 'fraction_numerical': 0.02049248058172203, 'mean_word_length': 2.613134328358209, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6821928', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1647, 'n_words': 524}