Skip to content

Commit

Permalink
[FLINK-5913] [gelly] Example drivers
Browse files Browse the repository at this point in the history
Replace existing and create new algorithm Driver implementations for
each of the library methods.

This closes apache#3635
  • Loading branch information
greghogan committed Mar 31, 2017
1 parent ded25be commit a48357d
Show file tree
Hide file tree
Showing 28 changed files with 919 additions and 1,536 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ public class Usage {

private static final Class[] DRIVERS = new Class[]{
org.apache.flink.graph.drivers.ClusteringCoefficient.class,
org.apache.flink.graph.drivers.Graph500.class,
org.apache.flink.graph.drivers.GraphMetrics.class,
org.apache.flink.graph.drivers.HITS.class,
org.apache.flink.graph.drivers.JaccardIndex.class,
org.apache.flink.graph.drivers.TriangleListing.class,
};

private static final Class[] EXAMPLES = new Class[]{
org.apache.flink.graph.examples.ConnectedComponents.class,
org.apache.flink.graph.examples.EuclideanGraphWeighing.class,
org.apache.flink.graph.examples.GSASingleSourceShortestPaths.class,
org.apache.flink.graph.examples.IncrementalSSSP.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.drivers;

import org.apache.commons.lang3.text.StrBuilder;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.drivers.output.CSV;
import org.apache.flink.graph.drivers.output.Print;
import org.apache.flink.graph.drivers.parameter.LongParameter;
import org.apache.flink.graph.library.similarity.AdamicAdar.Result;
import org.apache.flink.types.CopyableValue;

import static org.apache.flink.api.common.ExecutionConfig.PARALLELISM_DEFAULT;

/**
* Driver for {@link org.apache.flink.graph.library.similarity.AdamicAdar}.
*/
public class AdamicAdar<K extends CopyableValue<K>, VV, EV>
extends SimpleDriver<Result<K>>
implements Driver<K, VV, EV>, CSV, Print {

private LongParameter littleParallelism = new LongParameter(this, "little_parallelism")
.setDefaultValue(PARALLELISM_DEFAULT);

@Override
public String getName() {
return this.getClass().getSimpleName();
}

@Override
public String getShortDescription() {
return "similarity score weighted by centerpoint degree";
}

@Override
public String getLongDescription() {
return WordUtils.wrap(new StrBuilder()
.appendln("Adamic-Adar measures the similarity between vertex neighborhoods and is " +
"computed as the sum of the inverse logarithm of centerpoint degree over shared " +
"neighbors.")
.appendNewLine()
.append("The algorithm result contains two vertex IDs and the similarity score.")
.toString(), 80);
}

@Override
public void plan(Graph<K, VV, EV> graph) throws Exception {
int lp = littleParallelism.getValue().intValue();

result = graph
.run(new org.apache.flink.graph.library.similarity.AdamicAdar<K, VV, EV>()
.setLittleParallelism(lp));
}
}
Loading

0 comments on commit a48357d

Please sign in to comment.