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 or 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, so expect major changes in the future. Some code sections that will be changed in the immediate future include:

  • Improve the interface. Currently it is cumbersome to construct, options, embedders and embeddings. This should be easier.
  • Make a larger portion of the library accessible through the Python bindings
  • Provide more user friendly executables
  • 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.1.tar.gz (1.4 MB 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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

wembed-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

wembed-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

wembed-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

wembed-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: wembed-0.0.1.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for wembed-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f3617372500c6d4c8c34917754d9ad737fdfea28de9f98fa1b3df0c5177997a5
MD5 d424ea86eea0315c7423653777417b34
BLAKE2b-256 9c5c6102e3fd8f045a79258a7a80557ce5b6929e2d3e588b1f6554be96597ac1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wembed-0.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 018ade639f81037cb1b08b584f657d8a168bbd8010aaf01f3bc3ccc0923e66a0
MD5 3a6058960b1d82c83de77a466cf28adb
BLAKE2b-256 2876e205671550dda3ae7f6d2d85aed1d738bbd529f4fd2ba691b2ca43687546

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wembed-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d892f4404736aa0e4dfc24bad516b6c9b1d3c39cd5592aaac7e5b2570955d76b
MD5 65a60b9105afc8388695a17bdafa5a24
BLAKE2b-256 54d10dd61af1aa0b8a213c1b95360cd850b11ef78b9d4a82f55c989bba861791

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wembed-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1ddd2ea4b8477a0c7d7661ed95743638156763ed9c3c87282979b09e14d7d96
MD5 fe4d96863fa3a16dfb1979475d363f63
BLAKE2b-256 82bb601104feacc574e39fa75372389b9759f4d303777529d2f6b1886f6af995

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wembed-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 934de5e332dad68d488dbbb54c224f9761e1b2b3ec3143d7c40fc5eaa97e776d
MD5 9507c0c63a27f612109ad961bc359e93
BLAKE2b-256 8f20479cdc51447c61e9fdf2f58f4533029fef08a0c63f9ae748595bedfa7fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wembed-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e2e9d59e0a37a855825827cdc01fd60fee398d94cbd6b7cbb620e8c0895a4dd
MD5 a386c3b4dbe0d0ad848631cfaa2012cc
BLAKE2b-256 2979181503834a51e6f9c2a9d05259e4a4a18b9807b157db79bbbe86c82e2748

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