Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
This branch is 30 commits ahead, 3 commits behind Hanjun-Dai:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Implementation of "Learning Combinatorial Optimization Algorithms over Graphs" (

Step-by-step demo of MVC solution found by different methods. From left to right: (1) S2V-DQN (our method), (2) node-degree heuristic, (3) edge-degree heuristic demo

1. build

**** Below shows an example of MVC. For all the problems, you can follow the similar pipeline ****

Get the source code, and install all the dependencies.

git clone --recursive

build the graphnn library with the instructions here:

For each task, build the dynamic library. For example, to build the Minimum Vertex Cover library:

cd code/s2v_mvc/mvc_lib/
cp Makefile.example Makefile

customize your Makefile if necessary
( add CXXFLAGS += -DGPU_MODE in the Makefile if you want to run it in GPU mode)

make -j

Now you are all set with the C++ backend.

2. Experiments on synthetic data

Generate synthetic data

To generate the synthetic data for Minimum Vertex Cover task, you can do the following:

cd code/data_generator/mvc
modify parameters in

The above code will generate 1000 test graphs under /path/to/the/project/data/mvc

Training with n-step Q-learning

Navigate to the MVC folder and run the training script. Modify the script to change the parameters.

cd code/s2v_mvc

By default it will save all the model files, the logs under currentfolder/results. Note that the code will generate the data on the fly, including the validation dataset. So the training code itself doesn't rely on the data generator.

Test the performance

Navigate to the MVC folder and run the evaluation script. Modify the script to change the parameters. Make sure the parameters are consistent with your training script.

cd code/s2v_mvc

The above script will load the 1000 test graphs you generated before, and output the solution in a csv file, under the same results folder. Format of the csv for MVC:

cover size, cover_size a_1 a_2 a_3 ...., time in seconds

Here the second column shows a solution found by S2V-DQN, in the same order of how each node is picked. 

2. Experiments on real-world data

For TSP we test on part of the tsplib instances; For MVC and SCP, we use memetracker dataset; For MAXCUT, we test on optsicom dataset;

All the data can be found through the dropbox link below. Code folders that start with 'realworld' are for this set of experiments.

Reproducing the results that reported in the paper

Here is the link to the dataset that was used in the paper:


Please cite our work if you find our code/paper is useful to your work.

  title={Learning Combinatorial Optimization Algorithms over Graphs},
  author={Dai, Hanjun and Khalil, Elias B and Zhang, Yuyu and Dilkina, Bistra and Song, Le},
  journal={arXiv preprint arXiv:1704.01665},


Implementation of "Learning Combinatorial Optimization Algorithms over Graphs"







No releases published


No packages published


  • C++ 81.0%
  • Python 8.9%
  • Cuda 6.0%
  • Shell 2.7%
  • C 1.2%
  • Makefile 0.2%