{"id":16266936,"url":"https://github.com/kvignesh1420/rlap","last_synced_at":"2026-04-02T02:44:00.662Z","repository":{"id":198955653,"uuid":"476459044","full_name":"kvignesh1420/rlap","owner":"kvignesh1420","description":"[ICML 2023] Official implementation of \"A randomized schur complement based graph augmentor\"","archived":false,"fork":false,"pushed_at":"2024-06-29T07:56:37.000Z","size":410,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T21:32:53.501Z","etag":null,"topics":["contrastive-learning","graph-diffusion","graph-neural-networks","randomized-algorithms","schur-complement"],"latest_commit_sha":null,"homepage":"https://proceedings.mlr.press/v202/kothapalli23a.html","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/kvignesh1420.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-31T20:00:03.000Z","updated_at":"2024-12-10T08:22:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec3191be-c4af-42d1-bec8-9d01cc6f3818","html_url":"https://github.com/kvignesh1420/rlap","commit_stats":null,"previous_names":["kvignesh1420/rlap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvignesh1420%2Frlap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvignesh1420%2Frlap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvignesh1420%2Frlap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kvignesh1420%2Frlap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kvignesh1420","download_url":"https://codeload.github.com/kvignesh1420/rlap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244030752,"owners_count":20386533,"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":["contrastive-learning","graph-diffusion","graph-neural-networks","randomized-algorithms","schur-complement"],"created_at":"2024-10-10T17:43:28.332Z","updated_at":"2026-04-02T02:44:00.610Z","avatar_url":"https://github.com/kvignesh1420.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Randomized Schur Complement Views for Graph Contrastive Learning\n\nThis work introduces a randomized topological augmentor based on Schur complements for Graph Contrastive Learning (GCL). The `rLap` augmentor is written in C++ (with Python bindings) and uses [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page) for representing sparse matrices which aids in efficient traversal and indexing into matrices. Additionally, the relevant data structures for sampling edges are inspired from the [Laplacians.jl](https://github.com/danspielman/Laplacians.jl) effort.\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/gcl.png\"/\u003e\n  \u003cp align=\"center\"\u003e \u003cb\u003eGeneralized GCL framework.\u003c/b\u003e The augmentor is effective for GCL with varying design choices of encoders and objectives.\u003c/p\u003e\n\u003c/div\u003e\n\n\n\n_The motivation and methodology behind `rLap` is presented in my [ICML 2023](https://arxiv.org/abs/2306.04004) paper._\n\n## Citation\n\n\n```bibtex\n@inproceedings{Kothapalli2023RandomizedSC,\n  title={Randomized Schur Complement Views for Graph Contrastive Learning},\n  author={Vignesh Kothapalli},\n  booktitle={International Conference on Machine Learning},\n  year={2023}\n}\n```\n\n\n## Setup\n\n```bash\n# create virtual environment\n$ python3.9 -m virtualenv .venv\n$ source .venv/bin/activate\n\n# install torch and torch-geometric if not present\n$ pip install torch torch-geometric\n\n# install rlap\n$ pip install .\n```\n\n## Usage\n\nThe `rlap` API exposes a simple torch operation to obtain the randomized schur complement of a graph. A simple example is shown below:\n\n```py\nimport torch\nfrom torch_geometric.utils import barabasi_albert_graph, to_undirected\nimport rlap\n\nnum_nodes = 100\n# prepare a sample graph\nedge_index = barabasi_albert_graph(num_nodes=num_nodes, num_edges=num_nodes//2)\n\n# ensure the graph is undirected\nedge_index = to_undirected(edge_index=edge_index, num_nodes=num_nodes)\n\n# compute the randomized schur complement\nsc_edge_info = rlap.ops.approximate_cholesky(\n    edge_index=edge_index,\n    edge_weights=None, # pass the 1d weights tensor (for the edges) if needed\n    num_nodes=num_nodes,\n    num_remove=50, # number of nodes to eliminate\n    o_v=\"random\", # choose from [\"random\", \"degree\", \"coarsen\"]\n    o_n=\"asc\", # choose from [\"asc\", \"desc\", \"random\"]\n)\n\n# obtain the edge_index\nsc_edge_index = (torch.Tensor(sc_edge_info[:, :2]).long().t().to(edge_index.device))\n\n# obtain the edge_weights (if necessary)\nsc_edge_weights = torch.Tensor(sc_edge_info[:,-1]).t().to(edge_index.device)\n```\n\n### Benchmarks\n\nThe pytorch geometric implementation of the augmentor is based on the [PyGCL](https://github.com/PyGCL/PyGCL) library for reproducible experiments and is available in `augmentor_benchmarks.py`. Additionally, a DGL implementation is made available in `CCA-SSG/aug.py`.\n\nTo run the following scripts, change the directory to:\n\n```bash\n$ cd scripts\n```\n\nUse the following shell script to benchmark all the augmentors on node and graph classification datasets\n\n```bash\n$ bash run_augmentor_benchmarks.sh\n```\n\nUse the following python script to prepare the latex table of benchmark results. The table will be properly filled only when CPU and GPU based benchmarks have completed. _Interrupting the previous script to generate the table will lead to parsing errors for incomplete runs._\n\n```bash\n$ python prepare_augmentor_stats.py\n```\n\n\n### Node and graph classification experiments\n\nUse the following shell script to run **node classification** experiments using the **GRACE** design\n\n```bash\n$ bash run_node_shared.sh\n```\n\nUse the following shell script to run **node classification** experiments using the **MVGRL** design\n\n```bash\n$ bash run_node_dedicated.sh\n```\n\nUse the following shell script to run **graph classification** experiments using the **GraphCL** design\n\n```bash\n$ bash run_graph_shared.sh\n```\n\nUse the following shell script to run **graph classification** experiments using the **BGRL (g-l)** design\n\n```bash\n$ bash run_graph_shared_g2l.sh\n```\n\nUse the following python script to prepare the latex table of results\n\n```bash\n$ python prepare_final_stats.py\n```\n\n\n### Additional experiments\n\nUse the following shell script to run max singular value and edge count analysis of rlap variants\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/rlap_diffusion.png\" width=\"500px\" /\u003e\n  \u003cp align=\"center\"\u003e Applying \u003cb\u003erLap\u003c/b\u003e follwed by Diffusion is equivalent in expectation to Diffusion and sub-sampling  \u003c/p\u003e\n\u003c/div\u003e\n\n```bash\n$ python rlap_vc_spectral.py\n```\n\nUse the following shell script to plot edge counts of randomized schur complements after diffusion\n\n\n```bash\n$ python rlap_ppr_edge_plots.py\n```\n\n## Contributing\n\nPlease feel free to open [issues](https://github.com/kvignesh1420/rlap/issues) and create [pull requests](https://github.com/kvignesh1420/rlap/pulls) to fix bugs and improve performance.\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkvignesh1420%2Frlap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkvignesh1420%2Frlap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkvignesh1420%2Frlap/lists"}