This topic uses the single source shortest path (SSSP) algorithm as an example to describe how to submit a Graph job.

The method to submit a Graph job is basically the same as that to submit a MapReduce job.


  • JDK 1.6 or a later version is installed before you write, compile, and run MapReduce code.
    Note If you use Maven, you can search for odps-sdk-mapred in the Maven repository to find the latest version of SDK for Java. The following example shows the dependency required for the specified version of SDK for Java.
  • The MaxCompute client is deployed. For more information about how to deploy the MaxCompute client, see Install and configure the MaxCompute client. For more information about how to use the MaxCompute client, see MaxCompute client.


  1. Run the MaxCompute client.
  2. Execute the following statements to create the input table sssp_in and the output table sssp_out:
    CREATE TABLE sssp_in (v bigint, es string);
    CREATE TABLE sssp_out (v bigint, l bigint);

    For more information about the table creation statements, see Table operations.

  3. Upload data to the sssp_in table.
    We recommend that you create an sssp.txt file that contains the following data and save the file a directory on your on-premises machine. In this topic, the file is saved in D:\.
    1 2:2,3:1,4:4
    2 1:2,3:2,4:1
    3 1:1,2:2,5:1
    4 1:4,2:1,5:1
    5 3:1,4:1
    Run the following Tunnel command to upload data to the sssp_in table. Spaces are used as the delimiter between columns.
    tunnel u -fd " " D:\sssp.txt sssp_in;
  4. Compile SSSP code.
    Compile and debug SSSP code. Assume that the code is packaged into a file named odps-graph-example-sssp.jar.
    Note You need only to package the SSSP code. You do not need to package the SDK into odps-graph-example-sssp.jar.
  5. Add JAR resources. For more information about how to add resources, see Resource operations.
    add jar $LOCAL_JAR_PATH/odps-graph-example-sssp.jar;
  6. Run SSSP.
    jar -libjars odps-graph-example-sssp.jar -classpath $LOCAL_JAR_PATH/odps-graph-example-sssp.jar com.aliyun.odps.graph.example.SSSP 1 sssp_in sssp_out;
    When a Graph job is running, the command-line tool displays the instance ID, progress, and summary of the job. Sample command output:
    ID = 20130730160742915g******
    2013-07-31 00:18:36     SUCCESS
    Graph Input/Output
    Total input bytes=211
    Total input records=5
    Total output bytes=161
    Total output records=5
    Graph Statistics
    Total edges=14
    Total halted vertices=5
    Total sent messages=28
    Total supersteps=4
    Total vertices=5
    Total workers=1
    Graph Timers
    Average superstep time (milliseconds)=7
    Load time (milliseconds)=8
    Max superstep time (milliseconds) =14
    Max time superstep=0
    Min superstep time (milliseconds)=5
    Min time superstep=2
    Setup time (milliseconds)=277
    Shutdown time (milliseconds)=20
    Total superstep time (milliseconds)=30
    Total time (milliseconds)=344
    Note If you want to use the Graph feature, you can directly submit a Graph computing job.