{"id":13628279,"url":"https://github.com/benedekrozemberczki/role2vec","last_synced_at":"2025-07-07T16:38:49.236Z","repository":{"id":36527064,"uuid":"167860349","full_name":"benedekrozemberczki/role2vec","owner":"benedekrozemberczki","description":"A scalable Gensim implementation of \"Learning Role-based Graph Embeddings\" (IJCAI 2018).","archived":false,"fork":false,"pushed_at":"2022-11-06T21:10:54.000Z","size":7721,"stargazers_count":167,"open_issues_count":0,"forks_count":32,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-07T20:49:03.073Z","etag":null,"topics":["deep-learning","deepwalk","gensim","graph-embedding","graph-neural-network","graph-wavelet","implicit-factorization","machine-learning","network-embedding","network-science","node-embedding","node2vec","pytorch","representation-learning","research","sklearn","struc2vec","tensorflow","weisfeiler-lehman","word2vec"],"latest_commit_sha":null,"homepage":"https://karateclub.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benedekrozemberczki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["benedekrozemberczki"]}},"created_at":"2019-01-27T21:24:16.000Z","updated_at":"2025-03-23T13:31:40.000Z","dependencies_parsed_at":"2023-01-17T02:30:42.365Z","dependency_job_id":null,"html_url":"https://github.com/benedekrozemberczki/role2vec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benedekrozemberczki/role2vec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Frole2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Frole2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Frole2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Frole2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benedekrozemberczki","download_url":"https://codeload.github.com/benedekrozemberczki/role2vec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Frole2vec/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264113581,"owners_count":23559380,"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":["deep-learning","deepwalk","gensim","graph-embedding","graph-neural-network","graph-wavelet","implicit-factorization","machine-learning","network-embedding","network-science","node-embedding","node2vec","pytorch","representation-learning","research","sklearn","struc2vec","tensorflow","weisfeiler-lehman","word2vec"],"created_at":"2024-08-01T22:00:49.483Z","updated_at":"2025-07-07T16:38:49.216Z","avatar_url":"https://github.com/benedekrozemberczki.png","language":"Python","funding_links":["https://github.com/sponsors/benedekrozemberczki"],"categories":["Uncategorized","Python"],"sub_categories":["Uncategorized"],"readme":"Role2Vec\n==============================\n[![Arxiv](https://img.shields.io/badge/ArXiv-1802.02896-orange.svg?color=blue)](https://arxiv.org/abs/1802.02896) [![codebeat badge](https://codebeat.co/badges/13fe1050-b943-4095-b753-2896abc70f58)](https://codebeat.co/projects/github-com-benedekrozemberczki-role2vec-master) [![repo size](https://img.shields.io/github/repo-size/benedekrozemberczki/role2vec.svg)](https://github.com/benedekrozemberczki/role2vec/archive/master.zip) [![benedekrozemberczki](https://img.shields.io/twitter/follow/benrozemberczki?style=social\u0026logo=twitter)](https://twitter.com/intent/follow?screen_name=benrozemberczki)\n\n\nA scalable parallel **gensim** implementation of **Learning Role-based Graph Embeddings (IJCAI 2018)**.\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" src=\"orbit.png\"\u003e\n\u003c/p\u003e\n\n\n--------------------\n\n\n### Abstract\n\n\u003cp align=\"justify\"\u003e\nRandom walks are at the heart of many existing network embedding methods. However, such algorithms have many limitations that arise from the use of random walks, e.g., the features resulting from these methods are unable to transfer to new nodes and graphs as they are tied to vertex identity. In this work, we introduce the Role2Vec framework which uses the flexible notion of attributed random walks, and serves as a basis for generalizing existing methods such as DeepWalk, node2vec, and many others that leverage random walks. Our proposed framework enables these methods to be more widely applicable for both transductive and inductive learning as well as for use on graphs with attributes (if available). This is achieved by learning functions that generalize to new nodes and graphs. We show that our proposed framework is effective with an average AUC improvement of 16.55% while requiring on average 853x less space than existing methods on a variety of graphs.\n\nThe second-order random walk sampling methods were taken from the reference implementation of [Node2vec](https://github.com/aditya-grover/node2vec). \u003c/p\u003e\n\nThe model is now also available in the package [Karate Club](https://github.com/benedekrozemberczki/karateclub).\n\nThis repository provides an implementation of Role2Vec as described in the paper:\n\n\u003e Learning Role-based Graph Embeddings.\n\u003e Nesreen K. Ahmed, Ryan Rossi, John Boaz Lee, Theodore L. Willke, Rong Zhou, Xiangnan Kong, Hoda Eldardiry.\n\u003e StarAI workshop - IJCAI, 2018.\n\u003e [[Paper]](https://arxiv.org/abs/1802.02896)\n\n### Requirements\n\nThe codebase is implemented in Python 3.5.2. package versions used for development are just below.\n```\nnetworkx          2.4\ntqdm              4.28.1\nnumpy             1.15.4\npandas            0.23.4\ntexttable         1.5.0\nscipy             1.1.0\nargparse          1.1.0\ngensim            3.6.0\nscikit-learn      0.20.0\n```\n### Datasets\n\u003cp align=\"justify\"\u003e\nThe code takes the **edge list** of the graph in a csv file. Every row indicates an edge between two nodes separated by a comma. The first row is a header. Nodes should be indexed starting with 0. A sample graph for `Cora` is included in the  `input/` directory. \u003c/p\u003e\n\u003cp align=\"justify\"\u003e\nTraining the model is handled by the `src/main.py` script which provides the following command line arguments.\u003c/p\u003e\n\n#### Input and output options\n```\n  --graph-input      STR   Input graph path.   Default is `input/cora_edges.csv`.\n  --output           STR   Embeddings path.    Default is `output/cora_role2vec.csv`.\n```\n#### Random walk options\n```\n  --window-size      INT    Skip-gram window size.        Default is 5.\n  --walk-number      INT    Number of walks per node.     Default is 10.\n  --walk-length      INT    Number of nodes in walk.      Default is 80.\n  --sampling         STR    Sampling procedure.           Default is `first`.\n  --P                FLOAT  Return parameter.             Default is 1.0.\n  --Q                FLOAT  In-out parameter.             Default is 1.0.\n```\n#### Factorization options\n```\n  --dimensions      INT      Number of dimensions.      Default is 128\n  --down-sampling   FLOAT    Down sampling frequency.   Default is 0.001.\n  --alpha           FLOAT    Initial learning rate.     Default is 0.025.\n  --min-alpha       FLOAT    Final learning rate.       Default is 0.025.\n  --min-count       INT      Minimal feature count.     Default is 1\n  --workers         INT      Number of cores.           Default is 4.\n  --epochs          INT      Number of epochs.          Default is 10.\n```\n\n#### Feature creation options\n\n```\n  --features               STR     Feature extraction mechanism.         Default is `wl`.\n  --labeling-iterations    INT     Number of WL labeling iterations.     Default is 2.\n  --log-base               FLOAT   Log base for label creation.          Default is 1.5.\n  --graphlet-size          INT     Maximal graphlet size.                Default is 4.\n  --quantiles              INT     Number of quantiles for binning.      Default is 5.\n  --motif-compression      STR     Motif compression procedure.          Default is `string`.\n  --seed                   INT     Sklearn random seed.                  Default is 42.\n  --factors                INT     Factors for motif compression.        Default is 8.\n  --clusters               INT     Number of motif based labels.         Default is 50.\n  --beta                   FLOAT   Motif compression regularizer.        Default is 0.01.\n```\n\n### Examples\n\u003cp align=\"justify\"\u003e\nThe following commands learn a Role2Vec embedding. The first example trains an embedding based on the default dataset with standard hyperparameter settings.  The script saves the embedding at the default path.\u003c/p\u003e\n```\npython src/main.py\n```\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"600\", style=\"float: center;\" src=\"role2vec_run.jpg\"\u003e\n\u003c/p\u003e\n\nUsing the degree centrality as a structural feature.\n```\npython src/main.py --features degree\n```\nUsing the Weisfeiler-Lehman labeling as a structural feature.\n```\npython src/main.py --features wl\n```\nUsing motif based structural features with factorization compression.\n```\npython src/main.py --features motif --motif-compression factorization\n```\nUsing motif based structural features with factorization compression and a structural label number of 40.\n```\npython src/main.py --features motif --motif-compression factorization --clusters 40\n```\nUsing a custom factorization dimension for the embedding.\n```\npython src/main.py --dimensions 32\n```\nUsing second-order attributed ranom walks for sampling.\n```\npython src/main.py --sampling second --P 1 --Q 4\n```\n\n\n\n--------------------------------------------------------------------------------\n\n**License**\n\n- [GNU](https://github.com/benedekrozemberczki/Role2Vec/blob/master/LICENSE)\n\n--------------------------------------------------------------------------------\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Frole2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenedekrozemberczki%2Frole2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Frole2vec/lists"}