You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/24 19:48:44 UTC
[jira] [Commented] (FLINK-4648) Implement bipartite graph
generators
[ https://issues.apache.org/jira/browse/FLINK-4648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15883411#comment-15883411 ]
ASF GitHub Bot commented on FLINK-4648:
---------------------------------------
Github user greghogan commented on a diff in the pull request:
https://github.com/apache/flink/pull/2986#discussion_r103018907
--- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/bipartite/generator/CompleteBipartiteGraph.java ---
@@ -0,0 +1,109 @@
+/*
+ * 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.bipartite.generator;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.graph.Vertex;
+import org.apache.flink.graph.bipartite.BipartiteEdge;
+import org.apache.flink.graph.bipartite.BipartiteGraph;
+import org.apache.flink.graph.generator.GraphGeneratorUtils;
+import org.apache.flink.types.LongValue;
+import org.apache.flink.types.NullValue;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.LongValueSequenceIterator;
+
+/**
+ * Generate a complete bipartate graph where every top node is connected to every bottom node.
+ */
+public class CompleteBipartiteGraph
+ extends AbstractBipartiteGraphGenerator<LongValue, LongValue, NullValue, NullValue, NullValue> {
+
+ // Required to create the DataSource
+ private final ExecutionEnvironment env;
+
+ // Required configuration
+ private final long topVertexCount;
+ private final long bottomVertexCount;
+
+ public CompleteBipartiteGraph(ExecutionEnvironment env, long topVertexCount, long bottomVertexCount) {
+ this.env = env;
+ this.topVertexCount = topVertexCount;
+ this.bottomVertexCount = bottomVertexCount;
+ }
+
+ @Override
+ public BipartiteGraph<LongValue, LongValue, NullValue, NullValue, NullValue> generate() {
+ DataSet<Vertex<LongValue, NullValue>> topVertices
+ = GraphGeneratorUtils.vertexSequence(env, parallelism, topVertexCount);
+ DataSet<Vertex<LongValue, NullValue>> bottomVertices
+ = GraphGeneratorUtils.vertexSequence(env, parallelism, bottomVertexCount);
+
+ LongValueSequenceIterator iterator = new LongValueSequenceIterator(0, bottomVertexCount - 1);
+
+ DataSet<BipartiteEdge<LongValue, LongValue, NullValue>> edges = env
+ .fromParallelCollection(iterator, LongValue.class)
+ .setParallelism(parallelism)
+ .name("Bottom vertices iterator")
+ .flatMap(new EdgesToAllTopVertices(topVertexCount))
+ .setParallelism(parallelism)
+ .name("Complete graph edges");
+
+ return BipartiteGraph.fromDataSet(topVertices, bottomVertices, edges, env);
+ }
+
+ private static class EdgeGenerator
--- End diff --
Is this class unused?
> Implement bipartite graph generators
> ------------------------------------
>
> Key: FLINK-4648
> URL: https://issues.apache.org/jira/browse/FLINK-4648
> Project: Flink
> Issue Type: Sub-task
> Components: Gelly
> Reporter: Ivan Mushketyk
> Assignee: Ivan Mushketyk
>
> Implement generators for bipartite graphs.
> Should implement at least:
> * *BipartiteGraphGenerator* (maybe requires a better name) that will generate a bipartite graph where every vertex of one set is connected only to some vertices from another set
> * *CompleteBipartiteGraphGenerator* that will generate a graph where every vertex of one set is conneted to every vertex of another set
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)