[ 
https://issues.apache.org/jira/browse/FLINK-1741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14386964#comment-14386964
 ] 

ASF GitHub Bot commented on FLINK-1741:
---------------------------------------

Github user vasia commented on a diff in the pull request:

    https://github.com/apache/flink/pull/544#discussion_r27408109
  
    --- Diff: 
flink-staging/flink-gelly/src/main/java/org/apache/flink/graph/example/JaccardSimilarityMeasureExample.java
 ---
    @@ -0,0 +1,207 @@
    +/*
    + * 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.example;
    +
    +import org.apache.flink.api.common.ProgramDescription;
    +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.api.java.tuple.Tuple3;
    +import org.apache.flink.graph.Edge;
    +import org.apache.flink.graph.EdgeDirection;
    +import org.apache.flink.graph.Graph;
    +import org.apache.flink.graph.Vertex;
    +import org.apache.flink.graph.NeighborsFunction;
    +import org.apache.flink.graph.Triplet;
    +import org.apache.flink.graph.example.utils.JaccardSimilarityMeasureData;
    +import org.apache.flink.types.NullValue;
    +
    +import java.util.HashSet;
    +import java.util.Iterator;
    +
    +/**
    + * Given an undirected, unweighted graph,return a weighted graph where the 
edge values are equal
    + * to the Jaccard similarity coefficient - the number of common neighbors 
divided by the total number
    + * of neighbors - for the src and target vertices.
    + *
    + * <p>
    + * Input files are plain text files and must be formatted as follows:
    + * <br>
    + *         Edges are represented by pairs of srcVertexId, trgVertexId 
separated by tabs.
    + *         Edges themselves are separated by newlines.
    + *         For example: <code>1    2\n1    3\n</code> defines two edges 
1-2 and 1-3.
    + * </p>
    + *
    + * Usage <code> JaccardSimilarityMeasureExample &lt;edge path&gt; 
&lt;result path&gt;</code><br>
    + * If no parameters are provided, the program is run with default data from
    + * {@link 
org.apache.flink.graph.example.utils.JaccardSimilarityMeasureData}
    + */
    +@SuppressWarnings("serial")
    +public class JaccardSimilarityMeasureExample implements ProgramDescription 
{
    +
    +   public static void main(String [] args) throws Exception {
    +
    +           if(!parseParameters(args)) {
    +                   return;
    +           }
    +
    +           ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Edge<Long, Double>> edges = getEdgesDataSet(env);
    +
    +           Graph<Long, NullValue, Double> graph = Graph.fromDataSet(edges, 
env);
    +           // undirect the graph
    +           Graph<Long, NullValue, Double> undirectedGraph = 
graph.getUndirected();
    --- End diff --
    
    I wouldn't use "undirect" as a verb here :P
    Also, in the beginning you say "given an undirected, unweighted graph"... 
So, if you give an undirected graph as input, why call `getUndirected()` again?


> Add Jaccard Similarity Metric Example
> -------------------------------------
>
>                 Key: FLINK-1741
>                 URL: https://issues.apache.org/jira/browse/FLINK-1741
>             Project: Flink
>          Issue Type: Task
>          Components: Gelly
>    Affects Versions: 0.9
>            Reporter: Andra Lungu
>            Assignee: Andra Lungu
>
> http://www.inside-r.org/packages/cran/igraph/docs/similarity



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to