All Products
Search
Document Center

MaxCompute:Develop a Graph program using MaxCompute Studio

Last Updated:Mar 26, 2026

MaxCompute Studio lets you write, debug, package, and run Graph programs directly from IntelliJ IDEA. This guide walks you through the full development cycle.

Prerequisites

Before you begin, ensure that you have:

Write a Graph program

Create the Java classes

A Graph program requires two class types working together: a GraphLoader to load the graph from an input table, and a Vertex to define the computation each node performs. You must implement both.

Class typeRoleConfigured by
GraphLoaderReads the input table and constructs the graphsetGraphLoaderClass method of GraphJob
VertexDefines per-node computation; has id, value, halted, and edges propertiessetVertexClass method of GraphJob

The following steps use BaseLoadingVertexResolver (GraphLoader) and SSSP (Vertex) as examples.

  1. In the left-side navigation pane of the Project tab, choose src > main > java, right-click java, and choose New > MaxCompute Java.

    Create MaxCompute Java class

  2. Enter a Name and select GraphLoader or Vertex as the class type, then press Enter.

    If no package exists yet, enter packagename.classname. The system creates the package automatically.

    New class dialog

  3. Implement the Graph logic in the editor. For complete BaseLoadingVertexResolver and SSSP implementations, see SSSP.

Configure Maven dependencies

Add the following dependencies to pom.xml:

<dependency>
    <groupId>com.aliyun.odps</groupId>
    <artifactId>odps-sdk-core</artifactId>
    <version>0.48.0-public</version>
</dependency>
<dependency>
    <groupId>com.aliyun.odps</groupId>
    <artifactId>odps-sdk-graph</artifactId>
    <version>0.48.0-public</version>
</dependency>

<!-- Required for local testing -->
<dependency>
    <groupId>com.aliyun.odps</groupId>
    <artifactId>odps-graph-local</artifactId>
    <version>0.48.0-public</version>
</dependency>

After saving, verify that all three dependencies load successfully in the Maven pane.

Debug the Graph program

Run the Graph program locally to verify it produces the expected results.

  1. Right-click the Java file and select Run.

  2. In the Run/Debug Configurations dialog box, set the following parameters:

    ParameterDescription
    MaxCompute projectThe project in which to run the Graph program
    Download Record limitMaximum number of records to download. Default value: 100

    Run/Debug Configurations dialog

  3. Click OK. The Graph program runs in local execution mode, reading data from the specified table in the warehouse directory. View the output in the console. For details about the warehouse directory, see Overview.

Package and upload the Graph program

Package the Graph program into a JAR file and upload it to your MaxCompute project as a resource. For details, see Package, upload, and register a Java program.

Run the Graph program

  1. In the left-side navigation pane of IntelliJ IDEA, click Project Explorer.

  2. Right-click the name of your MaxCompute project and select Open in Console.

  3. In the Console section, run the following command:

    jar -libjars xxx.jar -classpath /Users/home/xxx.jar com.aliyun.odps.graph.examples.PageRank pagerank_in pagerank_out;

    Replace the placeholders based on your Graph program:

    PlaceholderDescription
    PageRankThe main class defined in your Graph program
    pagerank_inThe input table containing the graph data
    pagerank_outThe output table for results

    For additional command options, see Submit a MapReduce job.

What's next