Skip to main content

WEmbed python bindings to calculate weighted node embeddings

Project description

WEmbed

This project contains the source code of WEmbed for calculating low dimensional weighted node embeddings. The library is written in C++ and includes Python bindings. Below is an example of a two-dimensional embedding of [1] calculated by WEmbed.

This network represents the connection between internet routers. Node size represents weight calculated by WEmbed and colors indicate the country of the IP-Address reported by the respective router. Note that WEmbed had no knowledge of the countries during the embedding process and still managed to assign nodes from the same countries similar spacial coordinates.

[1] Boguñá, M., Papadopoulos, F. & Krioukov, D. Sustaining the Internet with hyperbolic mapping . Nat Commun 1, 62 (2010). https://doi.org/10.1038/ncomms1063

Installing the Python module

On most Linux systems we provide prebuild binaries, and you should be able to install WEmbed via pip. We recommend creating a new virtual environment before installing WEmbed.

python -m venv .venv
source .venv/bin/activate
pip install wembed

If your Linux system is not supported, or you are on Windows/Mac, pip will try to build WEmbed from source. In this case you have to make sure, that you install all necessary dependencies.

Installing Dependencies

In order to compile WEmbed you need to have Eigen3 and Boost headers installed. You can look at the development Dockerfile for more information. WEmbed also depends on a few other smaller libraries, these get downloaded automatically by CMake via Fetchcontent (so you do not have to worry about them), look at the root CMakeLists.txt for more information.

Compiling with CMake

The project uses CMake as a build tool (see the root CMakeLists.txt for more details). In order to build the binaries clone this repository, create a new folder and call CMake from it. A bin and lib folder will be created containing the executables and libraries.

git clone git@github.com:Vraier/wembed.git
cd wembed
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4

Structure

All source files can be found in src, this includes the library, python bindings and small example command line applications for C++ and Python. Unit tests using google test are found in tests. If you want to run WEmbed in a docker container, you can use the Dockerfile in docker_dev (docker_build is used to build python packages).

Usage and file formats

Both the C++ example and the Python example show how to use the code.

  • Start by creating a graph object. This can be done with a file or a vector of pairs representing an edge list. The graph is assumed to be undirected, connected and with consecutive node ids starting at zero. The file is expected to contain one line per edge and have to be given in only one direction. The repository contains a small example graph file.

  • Initialize the embedder with the graph object and an options object. You can modify the behavior of the embedder through this options object (e.g. changing the embedding dimension). You can calculate a single gradient descent step through calculateStep() or calculate until convergence with calculateEmbedding()

  • The final embedding can be written to file. It will contain one line per node. The first number of every line is the id of the node and the next d entries contain the coordinates of this node. The last entry represents the weight of the node

Work in progress

Note that WEmbed is still quiet experimental, expect major changes in the future. Some code sections that will be changed in the immediate future include:

  • Make a larger portion of the library accessible through the Python bindings
  • The repository contains some embedding code that is dead or outdated. This has to be updated or removed

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

wembed-0.0.2.tar.gz (93.8 kB view details)

Uploaded Source

Built Distributions

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

wembed-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

wembed-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

wembed-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

wembed-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

wembed-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file wembed-0.0.2.tar.gz.

File metadata

  • Download URL: wembed-0.0.2.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for wembed-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9c5d61929bb31a667b9d8c9a5a123e61ae7fa8ddf92575419a81711d224daf70
MD5 5562fbdb6fa18c1bfeb2c8a6d0c49498
BLAKE2b-256 d6a250fdb1e2ca7513a5fe5b1c5e1c1df70efc5bcde3e97ea5ea59917669abc0

See more details on using hashes here.

File details

Details for the file wembed-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wembed-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e7e71cc33836ac4de6e53a035646cffc86d9f3e5a2a978e6993c60780de1f3b
MD5 cc181d01d1f6e1612ac8fe1990bee141
BLAKE2b-256 806372a0e5ea9df4699eeadb436b684fcd61ed16bbe17a5caf174fe8714d98f0

See more details on using hashes here.

File details

Details for the file wembed-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wembed-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 53db78304d5a1b39fb713626dd92edcf50efedcc3d4ee69c30b87db94419fb9e
MD5 0b790dacec29a349e79b2d5e7d9513d5
BLAKE2b-256 a828d2cee29352e247b17dde24c5af24cb9f1692a69927dc6bd777592f794055

See more details on using hashes here.

File details

Details for the file wembed-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wembed-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b189e4845d532b772bb286f0014bdb2e6d6cb000fef3574f5868094540722862
MD5 58c0fdd043045d5b035256a71f21d1e0
BLAKE2b-256 0fe45c02ad354b531d5d5c27c8f2c1d684b2b1e742119ca8be06a598986aaf63

See more details on using hashes here.

File details

Details for the file wembed-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wembed-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d6988e3289851306406972dbc97b191099a186ac139067e090f3b86e80f1170
MD5 99dd02f5de63fe824b8b6cacffbe8884
BLAKE2b-256 df77ab94fd4ce7299b7e8a3cfa14493d46202708cae337a4db6848c2e0f2c0cb

See more details on using hashes here.

File details

Details for the file wembed-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wembed-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c24897974a94ea4f0e08130e76f13f5fae951cee30850685a6d905fe8edc4c5
MD5 c27427958b73c416cdb50fd59cb2fa2c
BLAKE2b-256 f6f6b7c457ebd4f6afce67e43b65db22ab35dd37b4ee6b0820adc0c881fd7cd9

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