wembed


Namewembed JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryWEmbed python bindings to calculate weighted node embeddings
upload_time2025-07-10 07:43:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2024 Nikolai Maas and Jean-Pierre von der Heydt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WEmbed

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

![](https://raw.githubusercontent.com/Vraier/wembed/refs/heads/main/assets/internet_graph.jpg)
<sub> WEmbed embedding of the internet graph by obtained from Boguñá, M., Papadopoulos, F. & Krioukov, D. Sustaining the Internet with hyperbolic mapping . Nat Commun 1, 62 (2010). https://doi.org/10.1038/ncomms1063 </sub>

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


## 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 (see section further below).


## Usage and file formats

Both the [C++ example](https://github.com/Vraier/wembed/blob/main/src/cli_wembed/) and the [Python example](https://github.com/Vraier/wembed/blob/main/python/examples/cli_example.py) show how to use the code.
A minimal working example for the python bindings might look like this:

```
import wembed

graph = wembed.readEdgeList("example.edg")
emb_opt = wembed.EmbedderOptions()
emb = wembed.Embedder(graph, emb_opt)

emb.calculateEmbedding()

wembed.writeCoordinates("example.emb", emb.getCoordinates(), emb.getWeights())
```

* 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 vertex ids starting at zero.
  The file is expected to contain one line per edge. Each edge should only be given in one direction.
  The repository contains a small [example graph file](https://github.com/Vraier/wembed/blob/main/assets/small_graph.edg).

* 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 vertex.
  The first number of every line is the id of the vertex and the next d entries contain the coordinates for this vertex.
  The last entry represents the weight of the vertex.


## Installing Dependencies

In order to compile WEmbed you need to have `Eigen3` and `Boost` headers installed.
You can look at the development [Dockerfile](https://github.com/Vraier/wembed/blob/main/docker_dev/Dockerfile) for more information.
WEmbed also depends on a few other smaller libraries, these get downloaded automatically by CMake via Fetchcontent (you do not have to worry about them), 
look at the root [CMakeLists.txt](https://github.com/Vraier/wembed/blob/main/CMakeLists.txt) for more information.


## Compiling with CMake

The project uses CMake as a build tool (see the [root CMakeLists.txt](https://github.com/Vraier/wembed/blob/main/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
```


## Project Structure

All C++ source files can be found in [src](https://github.com/Vraier/wembed/blob/main/src/), this includes the [library](https://github.com/Vraier/wembed/blob/main/src/embeddingLib/) and small example command line applications for [C++](https://github.com/Vraier/wembed/blob/main/src/cli_wembed/). The [python](https://github.com/Vraier/wembed/blob/main/python/) folder contains code for the python bindings and an example using these bindings.
Unit tests using google test are found in [tests](https://github.com/Vraier/wembed/blob/main/tests/).
If you want to run WEmbed in a docker container, you can use the Dockerfile in [docker_dev](https://github.com/Vraier/wembed/blob/main/docker_dev/) ([docker_build](https://github.com/Vraier/wembed/blob/main/docker_build/) is used to build python packages).


## Work in progress

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

* The repository contains some embedding code that is dead or outdated. This has to be updated or removed

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "wembed",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Jean-Pierre von der Heydt <heydt@kit.edu>, Nikolai Maas <nikolai.maas@kit.edu>",
    "download_url": "https://files.pythonhosted.org/packages/a1/45/a4600f1c8d92f137a726aa990785e4e87e041ba9daa370082dace282b059/wembed-0.0.3.tar.gz",
    "platform": null,
    "description": "# WEmbed\n\nThis project contains the source code of `WEmbed` for calculating low dimensional weighted vertex embeddings. \nThe library is written in C++ and includes Python bindings.\nBelow is an example of a two-dimensional embedding calculated by WEmbed.\n\n![](https://raw.githubusercontent.com/Vraier/wembed/refs/heads/main/assets/internet_graph.jpg)\n<sub> WEmbed embedding of the internet graph by obtained from Bogu\u00f1\u00e1, M., Papadopoulos, F. & Krioukov, D. Sustaining the Internet with hyperbolic mapping . Nat Commun 1, 62 (2010). https://doi.org/10.1038/ncomms1063 </sub>\n\nThis network represents the connection between internet routers.\nVertex size represents weight calculated by WEmbed and\ncolors indicate the country of the IP-Address of the respective router.\nNote that WEmbed had no knowledge of the countries during the embedding process and still managed to assign vertices from the same countries similar spacial coordinates.\n\n\n## Installing the Python module\n\nOn most Linux systems we provide prebuild binaries, and you should be able to install WEmbed via pip.\nWe recommend creating a new virtual environment before installing WEmbed.\n```\npython -m venv .venv\nsource .venv/bin/activate\npip install wembed\n```\nIf your Linux system is not supported, or you are on Windows/Mac, pip will try to build WEmbed from source. \nIn this case you have to make sure, that you install all necessary dependencies (see section further below).\n\n\n## Usage and file formats\n\nBoth the [C++ example](https://github.com/Vraier/wembed/blob/main/src/cli_wembed/) and the [Python example](https://github.com/Vraier/wembed/blob/main/python/examples/cli_example.py) show how to use the code.\nA minimal working example for the python bindings might look like this:\n\n```\nimport wembed\n\ngraph = wembed.readEdgeList(\"example.edg\")\nemb_opt = wembed.EmbedderOptions()\nemb = wembed.Embedder(graph, emb_opt)\n\nemb.calculateEmbedding()\n\nwembed.writeCoordinates(\"example.emb\", emb.getCoordinates(), emb.getWeights())\n```\n\n* Start by creating a graph object.\n  This can be done with a file or a `vector of pairs` representing an edge list.\n  The graph is assumed to be undirected, connected and with consecutive vertex ids starting at zero.\n  The file is expected to contain one line per edge. Each edge should only be given in one direction.\n  The repository contains a small [example graph file](https://github.com/Vraier/wembed/blob/main/assets/small_graph.edg).\n\n* Initialize the embedder with the `graph` object and an `options` object.\n  You can modify the behavior of the embedder through this options object (e.g. changing the embedding dimension).\n  You can calculate a single gradient descent step through `calculateStep()` or calculate until convergence with `calculateEmbedding()`.\n\n* The final embedding can be written to file.\n  It will contain one line per vertex.\n  The first number of every line is the id of the vertex and the next d entries contain the coordinates for this vertex.\n  The last entry represents the weight of the vertex.\n\n\n## Installing Dependencies\n\nIn order to compile WEmbed you need to have `Eigen3` and `Boost` headers installed.\nYou can look at the development [Dockerfile](https://github.com/Vraier/wembed/blob/main/docker_dev/Dockerfile) for more information.\nWEmbed also depends on a few other smaller libraries, these get downloaded automatically by CMake via Fetchcontent (you do not have to worry about them), \nlook at the root [CMakeLists.txt](https://github.com/Vraier/wembed/blob/main/CMakeLists.txt) for more information.\n\n\n## Compiling with CMake\n\nThe project uses CMake as a build tool (see the [root CMakeLists.txt](https://github.com/Vraier/wembed/blob/main/CMakeLists.txt) for more details).\nIn order to build the binaries clone this repository,\ncreate a new folder and call CMake from it.\nA `bin` and `lib` folder will be created containing the executables and libraries.\n```\ngit clone git@github.com:Vraier/wembed.git\ncd wembed\nmkdir release\ncd release\ncmake -DCMAKE_BUILD_TYPE=Release ..\nmake -j4\n```\n\n\n## Project Structure\n\nAll C++ source files can be found in [src](https://github.com/Vraier/wembed/blob/main/src/), this includes the [library](https://github.com/Vraier/wembed/blob/main/src/embeddingLib/) and small example command line applications for [C++](https://github.com/Vraier/wembed/blob/main/src/cli_wembed/). The [python](https://github.com/Vraier/wembed/blob/main/python/) folder contains code for the python bindings and an example using these bindings.\nUnit tests using google test are found in [tests](https://github.com/Vraier/wembed/blob/main/tests/).\nIf you want to run WEmbed in a docker container, you can use the Dockerfile in [docker_dev](https://github.com/Vraier/wembed/blob/main/docker_dev/) ([docker_build](https://github.com/Vraier/wembed/blob/main/docker_build/) is used to build python packages).\n\n\n## Work in progress\n\nNote that WEmbed is still quite experimental, expect major changes in the future. Some code sections that will be changed in the immediate future include:\n\n* The repository contains some embedding code that is dead or outdated. This has to be updated or removed\n",
    "bugtrack_url": null,
    "license": "MIT License\n         \n         Copyright (c) 2024 Nikolai Maas and Jean-Pierre von der Heydt\n         \n         Permission is hereby granted, free of charge, to any person obtaining a copy\n         of this software and associated documentation files (the \"Software\"), to deal\n         in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n         copies of the Software, and to permit persons to whom the Software is\n         furnished to do so, subject to the following conditions:\n         \n         The above copyright notice and this permission notice shall be included in all\n         copies or substantial portions of the Software.\n         \n         THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n         SOFTWARE.",
    "summary": "WEmbed python bindings to calculate weighted node embeddings",
    "version": "0.0.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4c1a89772e8ccc50ae67bdbb250bec89985f1158a42e9056548fcd03d07b5328",
                "md5": "14da0a510d930134f4111e26ca426aaf",
                "sha256": "2dbe9d35074199fc2c87fc2f98305c08be90e8d61c3e73658044eecd640bd50b"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "14da0a510d930134f4111e26ca426aaf",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.7",
            "size": 728579,
            "upload_time": "2025-07-10T07:43:53",
            "upload_time_iso_8601": "2025-07-10T07:43:53.564678Z",
            "url": "https://files.pythonhosted.org/packages/4c/1a/89772e8ccc50ae67bdbb250bec89985f1158a42e9056548fcd03d07b5328/wembed-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e403de433b75896a9056849b05652c902f7c379cc56998361fceaf80532c0871",
                "md5": "137b5ef5b47ea23e4b5cc28035228f6f",
                "sha256": "a48942927387c8ac5df605bb12ecde7eb332b042000da79f73daaef97bddb55c"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "137b5ef5b47ea23e4b5cc28035228f6f",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.7",
            "size": 729464,
            "upload_time": "2025-07-10T07:43:55",
            "upload_time_iso_8601": "2025-07-10T07:43:55.016416Z",
            "url": "https://files.pythonhosted.org/packages/e4/03/de433b75896a9056849b05652c902f7c379cc56998361fceaf80532c0871/wembed-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1f596ceb5d34c70ac43ab431415317e810069668f068d5b51f7260cca79745f3",
                "md5": "ea1fedfaa46e326fc62bc3ac829641e6",
                "sha256": "cbe3f22c269ec2bf65720e2fbbaf48da1517a3adc128f2c49397825fa293972b"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "ea1fedfaa46e326fc62bc3ac829641e6",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.7",
            "size": 728715,
            "upload_time": "2025-07-10T07:43:56",
            "upload_time_iso_8601": "2025-07-10T07:43:56.408951Z",
            "url": "https://files.pythonhosted.org/packages/1f/59/6ceb5d34c70ac43ab431415317e810069668f068d5b51f7260cca79745f3/wembed-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "79eaa5450a8013d5c0a0416c9bd1d2158fdab56ceff68194265f5f7c89f5cf49",
                "md5": "5435ca8a73e63ce2bbf7f7592aff66e8",
                "sha256": "bbf62f2426bbf232d2dda188b6f7eb36c9edf6bef0bcade3553624b0c7cc4c1d"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "5435ca8a73e63ce2bbf7f7592aff66e8",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.7",
            "size": 728299,
            "upload_time": "2025-07-10T07:43:57",
            "upload_time_iso_8601": "2025-07-10T07:43:57.416224Z",
            "url": "https://files.pythonhosted.org/packages/79/ea/a5450a8013d5c0a0416c9bd1d2158fdab56ceff68194265f5f7c89f5cf49/wembed-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "258ba5eee8a8a94aa13868247f5e5534ff3c35810fb98197223eb4ee7db5958b",
                "md5": "7a65ae19e07979bd351ff155bc107a45",
                "sha256": "3c4657a80c93f940455b3ac86e53bc05c588a03775a3fd7957ac50aaa84d0824"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "7a65ae19e07979bd351ff155bc107a45",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.7",
            "size": 728727,
            "upload_time": "2025-07-10T07:43:58",
            "upload_time_iso_8601": "2025-07-10T07:43:58.471975Z",
            "url": "https://files.pythonhosted.org/packages/25/8b/a5eee8a8a94aa13868247f5e5534ff3c35810fb98197223eb4ee7db5958b/wembed-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a145a4600f1c8d92f137a726aa990785e4e87e041ba9daa370082dace282b059",
                "md5": "15ba1593e8713d7ed6fda35429f8f942",
                "sha256": "c807ab5355a7e53ffd85e77cee4b42e213d8e04b0779e555641db9a5f7146ff6"
            },
            "downloads": -1,
            "filename": "wembed-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "15ba1593e8713d7ed6fda35429f8f942",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 1357889,
            "upload_time": "2025-07-10T07:43:59",
            "upload_time_iso_8601": "2025-07-10T07:43:59.612261Z",
            "url": "https://files.pythonhosted.org/packages/a1/45/a4600f1c8d92f137a726aa990785e4e87e041ba9daa370082dace282b059/wembed-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 07:43:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "wembed"
}
        
Elapsed time: 0.54865s