Skip to main content

nxt_gem: A Python module for Graph Embedding Methods

Project description

Python application Coverage Status Quality Gate Status

nxt_gem: Graph Embedding Methods

This package is an updated version of the GEM package of palash1992. Key differences are:

  • smaller codebase
  • unittests (more to come)
  • updated to current tensorflow and networkx version

GEM: Graph Embedding Methods

Many physical systems in the world involve interactions between different entities and can be represented as graphs. Understanding the structure and analyzing properties of graphs are hence paramount to developing insights into the physical systems. Graph embedding, which aims to represent a graph in a low dimensional vector space, takes a step in this direction. The embeddings can be used for various tasks on graphs such as visualization, clustering, classification and prediction.

GEM is a Python package which offers a general framework for graph embedding methods. It implements many state-of-the-art embedding techniques including Locally Linear Embedding, Laplacian Eigenmaps, Graph Factorization, Higher-Order Proximity preserved Embedding (HOPE), Structural Deep Network Embedding (SDNE) and node2vec. It is formatted such that new methods can be easily added for comparison. Furthermore, the framework implements several functions to evaluate the quality of obtained embedding including graph reconstruction, link prediction, visualization and node classification. It supports many edge reconstruction metrics including cosine similarity, euclidean distance and decoder based. For node classification, it defaults to one-vs-rest logistic regression classifier and supports other classifiers. For faster execution, C++ backend is integrated using Boost for supported methods. A paper showcasing the results using GEM on various real world datasets can be accessed through Graph Embedding Techniques, Applications, and Performance: A Survey. The library is also published as GEM: A Python package for graph embedding methods.

Please refer https://palash1992.github.io/GEM/ to access the readme as a webpage.

Update: Note that this is a library for static graph embedding methods. For evolving graph embedding methods, please refer DynamicGEM. We also recently released Youtube dynamic graph data set which can be found at YoutubeGraph-Dyn.

The module was developed and is maintained by Palash Goyal.

Implemented Methods

GEM implements the following graph embedding techniques:

A survey of these methods can be found in Graph Embedding Techniques, Applications, and Performance: A Survey.

Graph Format

We store all graphs using the DiGraph as directed weighted graph in python package networkx. The weight of an edge is stored as attribute "weight". We save each edge in undirected graph as two directed edges.

The graphs are saved using nx.write_gpickle in the networkx format and can be loaded by using nx.read_gpickle.

Repository Structure

  • gem/embedding: existing approaches for graph embedding, where each method is a separate file
  • gem/evaluation: evaluation tasks for graph embedding, including graph reconstruction, link prediction, node classification and visualization
  • gem/utils: utility functions for graph manipulation, evaluation and etc.
  • gem/data: input test graph (currently has Zachary's Karate graph)
  • gem/c_src: source files for methods implemented in C++
  • gem/c_ext: Python interface for source files in c_src using Boost.Python

Dependencies

nxt_gem is tested to work on Python 3.9

The required dependencies are: Numpy >= 1.12.0, SciPy >= 0.19.0, Networkx >= 2.4, Scikit-learn >= 0.18.1.

To run SDNE, GEM requires Theano >= 0.9.0 and tensorflow.

In case of Python 3, make sure it was compiled with ./configure --enable-shared, and that you have /usr/local/bin/python in your LD_LIBRARY_PATH.

Install

We recommend using uv for fast, reliable dependency management.

uv pip install .

If you don't use uv but want to install nxt_gem, please just run

pip install .

Or installing via pip with git:

pip install git+https://github.com/jernsting/nxt_gem.git

and using uv similar:

uv pip install git+https://github.com/jernsting/nxt_gem.git

Usage

See examples.

Cite

@article{goyal2017graph,
    title = "Graph embedding techniques, applications, and performance: A survey",
    journal = "Knowledge-Based Systems",
    year = "2018",
    issn = "0950-7051",
    doi = "https://doi.org/10.1016/j.knosys.2018.03.022",
    url = "http://www.sciencedirect.com/science/article/pii/S0950705118301540",
    author = "Palash Goyal and Emilio Ferrara",
    keywords = "Graph embedding techniques, Graph embedding applications, Python graph embedding methods GEM library"
}
@article{goyal3gem,
  title={GEM: A Python package for graph embedding methods},
  author={Goyal, Palash and Ferrara, Emilio},
  journal={Journal of Open Source Software},
  volume={3},
  number={29},
  pages={876}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nxt_gem-3.0.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nxt_gem-3.0.0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file nxt_gem-3.0.0.tar.gz.

File metadata

  • Download URL: nxt_gem-3.0.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nxt_gem-3.0.0.tar.gz
Algorithm Hash digest
SHA256 60f9f1e736430dfc6c585e3dcdaef2e12c9de3728ed2f55e0a67d74c18ce5fc0
MD5 c61e6732856707d5e0dd93aef56d8e6b
BLAKE2b-256 f5b364013dd51b4a47c7fb9c66d8a4b97bcd5462f86e821fd7a75ff58d502610

See more details on using hashes here.

File details

Details for the file nxt_gem-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: nxt_gem-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nxt_gem-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14dcfc854befc0a7fe56b2335ad0a7c02af50c884233c839004ac8e46dccaa7c
MD5 f6507a350710d2c980a6323ee4d34ff0
BLAKE2b-256 1470f1ba1c8510dc13f17c9f309bba98d2ad3cd70d42a68b478fcd18801d7404

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page