Algorithm drivers provide reusable implementations of graph algorithms that can be executed through the Runner framework or used programmatically. Each driver implements the Driver interface and supports configurable parameters and multiple output formats.
Base interface for all graph algorithm drivers.
/**
* A driver for one or more graph algorithms and/or analytics
* Coordinates algorithm execution with input graphs
*/
public interface Driver<K, VV, EV> extends Parameterized {
/**
* A one-line description presented in algorithm listings
* @return Short description of the algorithm
*/
String getShortDescription();
/**
* A multi-line description presented in algorithm usage help
* @return Detailed description of the algorithm
*/
String getLongDescription();
/**
* Execute algorithms and analytics on the input graph
* The execution plan is finalized in the output methods
* @param graph Input graph to process
* @throws Exception if algorithm execution fails
*/
void plan(Graph<K, VV, EV> graph) throws Exception;
}Link analysis algorithm that scores vertices by the number and quality of incoming links.
/**
* PageRank algorithm driver using iterative computation
* Scores vertices based on link structure and random walk model
*/
public class PageRank<K, VV, EV> extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Print {
public String getName();
public String getShortDescription(); // "score vertices by the number and quality of incoming links"
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
dampingFactor (DoubleParameter): Random walk restart probability (default: 0.85, range: 0.0-1.0)iterationConvergence (IterationConvergence): Maximum iterations and convergence threshold (default: 10 iterations)Usage Example:
--algorithm PageRank --dampingFactor 0.9 --iterationConvergence "20;0.001"Finds connected components in graphs using the gather-sum-apply (GSA) approach.
/**
* Connected Components algorithm driver using GSA implementation
* Identifies connected components by propagating minimum vertex IDs
* Requires vertex type to be Comparable for minimum ID computation
*/
public class ConnectedComponents<K extends Comparable<K>, VV, EV>
extends ParameterizedBase
implements Driver<K, VV, EV>, CSV, Hash, Print {
public String getName();
public String getShortDescription(); // "ConnectedComponents"
public String getLongDescription(); // "ConnectedComponents"
public void plan(Graph<K, VV, EV> graph) throws Exception;
public void hash(String executionName) throws Exception;
public void print(String executionName) throws Exception;
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
}Configuration Parameters: None (uses default GSA configuration)
Usage Example:
--algorithm ConnectedComponentsHyperlink-Induced Topic Search algorithm that scores vertices as hubs and authorities.
/**
* HITS algorithm driver using iterative computation
* Computes hub and authority scores based on link structure
*/
public class HITS<K, VV, EV> extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Print {
public String getName();
public String getShortDescription(); // "score vertices as hubs and authorities"
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
iterationConvergence (IterationConvergence): Maximum iterations and convergence threshold (default: 10 iterations)Usage Example:
--algorithm HITS --iterationConvergence "15;0.0001"Computes similarity scores between vertices weighted by the degree of common neighbors.
/**
* Adamic-Adar similarity algorithm driver
* Computes similarity scores weighted by centerpoint degree
*/
public class AdamicAdar<K extends CopyableValue<K>, VV, EV>
extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Print {
public String getName();
public String getShortDescription(); // "similarity score weighted by centerpoint degree"
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
minRatio (DoubleParameter): Minimum ratio threshold for results (default: 0.0, min: 0.0)minScore (DoubleParameter): Minimum score threshold for results (default: 0.0, min: 0.0)littleParallelism (LongParameter): Parallelism setting for small operationsUsage Example:
--algorithm AdamicAdar --minRatio 0.1 --minScore 0.5 --littleParallelism 1Computes local clustering coefficients for vertices in the graph.
/**
* Clustering Coefficient algorithm driver
* Computes local clustering coefficient for each vertex
*/
public class ClusteringCoefficient<K extends CopyableValue<K>, VV, EV>
extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Print {
public String getName();
public String getShortDescription();
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
minRatio (DoubleParameter): Minimum ratio threshold for resultsminScore (DoubleParameter): Minimum score threshold for resultslittleParallelism (LongParameter): Parallelism settingComputes Jaccard similarity coefficients between vertex neighborhoods.
/**
* Jaccard Index similarity algorithm driver
* Computes Jaccard similarity coefficient between vertex pairs
*/
public class JaccardIndex<K extends CopyableValue<K>, VV, EV>
extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Print {
public String getName();
public String getShortDescription();
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
minRatio (DoubleParameter): Minimum ratio threshold for resultsminScore (DoubleParameter): Minimum score threshold for resultslittleParallelism (LongParameter): Parallelism settingEnumerates all triangles (3-cycles) in the graph.
/**
* Triangle Listing algorithm driver
* Enumerates all triangles in the input graph
*/
public class TriangleListing<K extends CopyableValue<K>, VV, EV>
extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Hash, Print {
public String getName();
public String getShortDescription();
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void hash(String executionName) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
minRatio (DoubleParameter): Minimum ratio threshold for resultsminScore (DoubleParameter): Minimum score threshold for resultslittleParallelism (LongParameter): Parallelism settingComputes comprehensive graph metrics for directed or undirected graphs.
/**
* Graph Metrics algorithm driver
* Computes vertex and edge metrics for graph analysis
*/
public class GraphMetrics<K extends Comparable<K>, VV, EV>
extends ParameterizedBase
implements Driver<K, VV, EV>, Hash, Print {
public String getName();
public String getShortDescription(); // "compute vertex and edge metrics"
public String getLongDescription();
public void plan(Graph<K, VV, EV> graph) throws Exception;
public void hash(String executionName) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters:
order (ChoiceParameter): Graph type - "directed" or "undirected" (default: "directed")
Computed Metrics:
Usage Example:
--algorithm GraphMetrics --order directedSimple driver that outputs the graph as an edge list for inspection or conversion.
/**
* Edge List driver for graph output
* Outputs the input graph as a simple edge list
*/
public class EdgeList<K, VV, EV> extends SimpleDriver<K, VV, EV, Result<K>>
implements CSV, Hash, Print {
public String getName();
public String getShortDescription();
public String getLongDescription();
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
public void hash(String executionName) throws Exception;
public void print(String executionName) throws Exception;
}Configuration Parameters: None (direct edge list output)
Abstract base class for drivers that produce a single result DataSet with integrated output capabilities.
/**
* Base driver class for algorithms producing a single result DataSet
* Provides common functionality for result handling and output formatting
* Implements standard output interfaces for CSV, Print, and Hash operations
*/
public abstract class SimpleDriver<K, VV, EV, R extends PrintableResult>
extends ParameterizedBase implements Driver<K, VV, EV> {
/**
* Abstract method for algorithm-specific graph processing logic
* Subclasses implement their specific algorithm here
* @param graph Input graph to process
* @return DataSet containing algorithm results
* @throws Exception if algorithm execution fails
*/
protected abstract DataSet<R> simplePlan(Graph<K, VV, EV> graph) throws Exception;
/**
* Get the result DataSet from the last algorithm execution
* @return DataSet containing algorithm results, or null if not executed
*/
protected DataSet<R> getResult();
/**
* Implementation of Driver interface - coordinates algorithm execution
* Calls simplePlan() and stores result for output operations
* @param graph Input graph to process
* @throws Exception if algorithm execution fails
*/
public void plan(Graph<K, VV, EV> graph) throws Exception;
/**
* Compute and print hash of algorithm results for verification
* @param executionName Name to display with hash output
* @throws Exception if hash computation fails
*/
public void hash(String executionName) throws Exception;
/**
* Print algorithm results to console for inspection
* @param executionName Name to display with printed output
* @throws Exception if printing fails
*/
public void print(String executionName) throws Exception;
/**
* Write algorithm results to CSV file with configurable formatting
* @param filename Output file path
* @param lineDelimiter Line separator (e.g., "\n")
* @param fieldDelimiter Field separator (e.g., ",")
* @throws Exception if file writing fails
*/
public void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
}Base class providing common parameter management functionality.
/**
* Base class for parameterized components
* Provides common parameter parsing and validation functionality
*/
public abstract class ParameterizedBase implements Parameterized {
public String getName();
public String getUsage();
public void configure(ParameterTool parameterTool) throws ProgramParametrizationException;
// Protected methods for parameter management
protected void addParameter(Parameter parameter);
protected String getParametersListing();
}// Result wrapper for algorithm outputs
class Result<K> {
// Contains algorithm-specific result data
}
// Output format interfaces
interface CSV {
void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
}
interface Print {
void print(String executionName) throws Exception;
}
interface Hash {
void hash(String executionName) throws Exception;
}
// Type constraints for certain algorithms
interface CopyableValue<T> extends Value {
void copyTo(T target);
T copy();
}
interface Comparable<T> {
int compareTo(T other);
}