{"id":13481012,"url":"https://github.com/benedekrozemberczki/graph2vec","last_synced_at":"2025-04-04T01:05:12.179Z","repository":{"id":41300876,"uuid":"140419579","full_name":"benedekrozemberczki/graph2vec","owner":"benedekrozemberczki","description":"A parallel implementation of \"graph2vec: Learning Distributed Representations of Graphs\" (MLGWorkshop 2017).","archived":false,"fork":false,"pushed_at":"2022-11-06T21:15:35.000Z","size":222,"stargazers_count":913,"open_issues_count":1,"forks_count":168,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T00:05:12.245Z","etag":null,"topics":["deepwalk","diff2vec","gemsec","graph-embedding","graph-kernel","graph-wavelet","graph2vec","implicit-matrix-factorization","kernel","machine-learning","matrix-factorization","node-embedding","node2vec","noise-contrastive-estimation","struc2vec","subgraph2vec","transformer","unsupervised-learning","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":"2018-07-10T11:04:51.000Z","updated_at":"2025-03-23T20:29:04.000Z","dependencies_parsed_at":"2023-01-22T09:45:46.093Z","dependency_job_id":null,"html_url":"https://github.com/benedekrozemberczki/graph2vec","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Fgraph2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Fgraph2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Fgraph2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Fgraph2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benedekrozemberczki","download_url":"https://codeload.github.com/benedekrozemberczki/graph2vec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247099074,"owners_count":20883309,"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":["deepwalk","diff2vec","gemsec","graph-embedding","graph-kernel","graph-wavelet","graph2vec","implicit-matrix-factorization","kernel","machine-learning","matrix-factorization","node-embedding","node2vec","noise-contrastive-estimation","struc2vec","subgraph2vec","transformer","unsupervised-learning","weisfeiler-lehman","word2vec"],"created_at":"2024-07-31T17:00:47.625Z","updated_at":"2025-04-04T01:05:12.161Z","avatar_url":"https://github.com/benedekrozemberczki.png","language":"Python","funding_links":["https://github.com/sponsors/benedekrozemberczki"],"categories":["Factorization","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"Graph2Vec\n---------\n\n[![Arxiv](https://img.shields.io/badge/ArXiv-1707.05005-orange.svg)](https://arxiv.org/abs/1707.05005) [![codebeat badge](https://codebeat.co/badges/2b0535b8-2106-4570-ae43-e635405c9a0b)](https://codebeat.co/projects/github-com-benedekrozemberczki-graph2vec-master) [![repo size](https://img.shields.io/github/repo-size/benedekrozemberczki/Graph2Vec.svg)](https://github.com/benedekrozemberczki/Graph2Vec/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### Abstract\n----------\n\n\u003cp align=\"justify\"\u003eRecent works on representation learning for graph structured data predominantly focus on learning distributed representations of graph substructures such as nodes and subgraphs. However, many graph analytics tasks such as graph classification and clustering require representing entire graphs as fixed length feature vectors. While the aforementioned approaches are naturally unequipped to learn such representations, graph kernels remain as the most effective way of obtaining them. However, these graph kernels use handcrafted features (e.g., shortest paths, graphlets, etc.) and hence are hampered by problems such as poor generalization. To address this limitation, in this work, we propose a neural embedding framework named graph2vec to learn data-driven distributed representations of arbitrary sized graphs. graph2vec's embeddings are learnt in an unsupervised manner and are task agnostic. Hence, they could be used for any downstream task such as graph classification, clustering and even seeding supervised representation learning approaches. Our experiments on several benchmark and large real-world datasets show that graph2vec achieves significant improvements in classification and clustering accuracies over substructure representation learning approaches and are competitive with state-of-the-art graph kernels. \n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"720\" src=\"graph_embedding.jpeg\"\u003e\n\u003c/p\u003e\n\nThe model is now also available in the [Karate Club](https://github.com/benedekrozemberczki/karateclub) package.\n\nThis repository provides an implementation for *graph2vec* as it is described in:\n\u003e graph2vec: Learning distributed representations of graphs.\n\u003e Narayanan, Annamalai and Chandramohan, Mahinthan and Venkatesan, Rajasekar and Chen, Lihui and Liu, Yang\n\u003e MLG 2017, 13th International Workshop on Mining and Learning with Graphs (MLGWorkshop 2017).\n\nThe original TensorFlow implementation is available [[here]](https://github.com/MLDroid/graph2vec_tf).\n\n### Requirements\n\nThe codebase is implemented in Python 3.5.2 | Anaconda 4.2.0 (64-bit). Package versions used for development are just below.\n```\njsonschema        2.6.0\ntqdm              4.28.1\nnumpy             1.15.4\npandas            0.23.4\ntexttable         1.5.0\ngensim            3.6.0\nnetworkx          2.4\njoblib            0.13.0\nlogging           0.4.9.6  \n```\n\n### Datasets\n\u003cp align=\"justify\"\u003e\nThe code takes an input folder with json files. Every file is a graph and files have a numeric index as a name. The json files have two keys. The first key called \"edges\" corresponds to the edge list of the graph. The second key \"features\" corresponds to the node features. If the second key is not present the WL machine defaults to use the node degree as a feature.  A sample graph dataset from NCI1 is included in the `dataset/` directory.\u003c/p\u003e\n\n### Options\n\nLearning of the embedding is handled by the `src/graph2vec.py` script which provides the following command line arguments.\n\n#### Input and output options\n```\n  --input-path   STR    Input folder.           Default is `dataset/`.\n  --output-path  STR    Embeddings path.        Default is `features/nci1.csv`.\n```\n#### Model options\n```\n  --dimensions     INT          Number of dimensions.                             Default is 128.\n  --workers        INT          Number of workers.                                Default is 4.\n  --epochs         INT          Number of training epochs.                        Default is 1.\n  --min-count      INT          Minimal feature count to keep.                    Default is 5.\n  --wl-iterations  INT          Number of feature extraction recursions.          Default is 2.\n  --learning-rate  FLOAT        Initial learning rate.                            Default is 0.025.\n  --down-sampling  FLOAT        Down sampling rate for frequent features.         Default is 0.0001.\n```\n\n### Examples\n\u003cp align=\"justify\"\u003e\nThe following commands learn an embedding of the graphs and writes it to disk. The node representations are ordered by the ID. Creating a graph2vec embedding of the default dataset with the default hyperparameter settings. Saving the embedding at the default path.\u003c/p\u003e\n\n```sh\n$ python src/graph2vec.py\n```\n\nCreating an embedding of an other dataset. Saving the output in a custom place.\n\n```sh\n$ python src/graph2vec.py --input-path new_data/ --output-path features/nci2.csv\n```\n\nCreating an embedding of the default dataset in 32 dimensions.\n\n```sh\n$ python src/graph2vec.py --dimensions 32\n```\n-----------------------------------------------\n\n**License**\n\n- [GNU License](https://github.com/benedekrozemberczki/graph2vec/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Fgraph2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenedekrozemberczki%2Fgraph2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Fgraph2vec/lists"}