{"id":13788795,"url":"https://github.com/snap-stanford/GraphRNN","last_synced_at":"2025-05-12T03:30:49.308Z","repository":{"id":53061320,"uuid":"136380528","full_name":"snap-stanford/GraphRNN","owner":"snap-stanford","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-08T21:50:34.000Z","size":12200,"stargazers_count":422,"open_issues_count":6,"forks_count":113,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-05-08T00:17:14.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snap-stanford.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-06T20:05:45.000Z","updated_at":"2025-05-03T01:39:29.000Z","dependencies_parsed_at":"2022-08-24T00:40:54.033Z","dependency_job_id":null,"html_url":"https://github.com/snap-stanford/GraphRNN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FGraphRNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FGraphRNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FGraphRNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FGraphRNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snap-stanford","download_url":"https://codeload.github.com/snap-stanford/GraphRNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253667942,"owners_count":21944943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T21:00:53.680Z","updated_at":"2025-05-12T03:30:44.290Z","avatar_url":"https://github.com/snap-stanford.png","language":"Python","funding_links":[],"categories":["TensorFlow Implementations"],"sub_categories":[],"readme":"# GraphRNN: Generating Realistic Graphs with Deep Auto-regressive Model\nThis repository is the official PyTorch implementation of GraphRNN, a graph generative model using auto-regressive model.\n\n[Jiaxuan You](https://cs.stanford.edu/~jiaxuan/)\\*, [Rex Ying](https://cs.stanford.edu/people/rexy/)\\*, [Xiang Ren](http://www-bcf.usc.edu/~xiangren/), [William L. Hamilton](https://stanford.edu/~wleif/), [Jure Leskovec](https://cs.stanford.edu/people/jure/index.html), [GraphRNN: Generating Realistic Graphs with Deep Auto-regressive Model](https://arxiv.org/abs/1802.08773) (ICML 2018)\n\n## Installation\nInstall PyTorch following the instuctions on the [official website](https://pytorch.org/). The code has been tested over PyTorch 0.2.0 and 0.4.0 versions.\n```bash\nconda install pytorch torchvision cuda90 -c pytorch\n```\nThen install the other dependencies.\n```bash\npip install -r requirements.txt\n```\n\n## Test run\n```bash\npython main.py\n```\n\n## Code description\nFor the GraphRNN model:\n`main.py` is the main executable file, and specific arguments are set in `args.py`.\n`train.py` includes training iterations and calls `model.py` and `data.py`\n`create_graphs.py` is where we prepare target graph datasets.\n\nFor baseline models: \n* B-A and E-R models are implemented in `baselines/baseline_simple.py`.\n* [Kronecker graph model](https://cs.stanford.edu/~jure/pubs/kronecker-jmlr10.pdf) is implemented in the SNAP software, which can be found in `https://github.com/snap-stanford/snap/tree/master/examples/krongen` (for generating Kronecker graphs), and `https://github.com/snap-stanford/snap/tree/master/examples/kronfit` (for learning parameters for the model).\n* MMSB is implemented using the EDWARD library (http://edwardlib.org/), and is located in\n  `baselines`.\n* We implemented the DeepGMG model based on the instructions of their [paper](https://arxiv.org/abs/1803.03324) in `main_DeepGMG.py`.\n* We implemented the GraphVAE model based on the instructions of their [paper](https://arxiv.org/abs/1802.03480) in `baselines/graphvae`.\n\nParameter setting:\nTo adjust the hyper-parameter and input arguments to the model, modify the fields of `args.py`\naccordingly.\nFor example, `args.cuda` controls which GPU is used to train the model, and `args.graph_type`\nspecifies which dataset is used to train the generative model. See the documentation in `args.py`\nfor more detailed descriptions of all fields.\n\n## Outputs\nThere are several different types of outputs, each saved into a different directory under a path prefix. The path prefix is set at `args.dir_input`. Suppose that this field is set to `./`:\n* `./graphs` contains the pickle files of training, test and generated graphs. Each contains a list\n  of networkx object.\n* `./eval_results` contains the evaluation of MMD scores in txt format.\n* `./model_save` stores the model checkpoints\n* `./nll` saves the log-likelihood for generated graphs as sequences.\n* `./figures` is used to save visualizations (see Visualization of graphs section).\n\n## Evaluation\nThe evaluation is done in `evaluate.py`, where user can choose which settings to evaluate.\nTo evaluate how close the generated graphs are to the ground truth set, we use MMD (maximum mean discrepancy) to calculate the divergence between two _sets of distributions_ related to\nthe ground truth and generated graphs.\nThree types of distributions are chosen: degree distribution, clustering coefficient distribution.\nBoth of which are implemented in `eval/stats.py`, using multiprocessing python\nmodule. One can easily extend the evaluation to compute MMD for other distribution of graphs.\n\nWe also compute the orbit counts for each graph, represented as a high-dimensional data point. We then compute the MMD\nbetween the two _sets of sampled points_ using ORCA (see http://www.biolab.si/supp/orca/orca.html) at `eval/orca`. \nOne first needs to compile ORCA by \n```bash\ng++ -O2 -std=c++11 -o orca orca.cpp` \n```\nin directory `eval/orca`.\n(the binary file already in repo works in Ubuntu). \n\nTo evaluate, run \n```bash\npython evaluate.py\n```\nArguments specific to evaluation is specified in class\n`evaluate.Args_evaluate`. Note that the field `Args_evaluate.dataset_name_all` must only contain\ndatasets that are already trained, by setting args.graph_type to each of the datasets and running\n`python main.py`.\n\n## Visualization of graphs\nThe training, testing and generated graphs are saved at 'graphs/'.\nOne can visualize the generated graph using the function `utils.load_graph_list`, which loads the\nlist of graphs from the pickle file, and `util.draw_graph_list`, which plots the graph using\nnetworkx. \n\n\n## Misc\nJesse Bettencourt and Harris Chan have made a great [slide](https://duvenaud.github.io/learn-discrete/slides/graphrnn.pdf) introducing GraphRNN in Prof. David Duvenaud’s seminar course [Learning Discrete Latent Structure](https://duvenaud.github.io/learn-discrete/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnap-stanford%2FGraphRNN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnap-stanford%2FGraphRNN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnap-stanford%2FGraphRNN/lists"}