Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pavlin-policar/fdeb
Force-Directed Edge Bundling (FDEB)
https://github.com/pavlin-policar/fdeb
Last synced: 15 days ago
JSON representation
Force-Directed Edge Bundling (FDEB)
- Host: GitHub
- URL: https://github.com/pavlin-policar/fdeb
- Owner: pavlin-policar
- License: bsd-3-clause
- Created: 2023-04-21T10:01:34.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-04-21T17:15:59.000Z (over 1 year ago)
- Last Synced: 2024-10-07T17:04:31.546Z (about 1 month ago)
- Language: Python
- Size: 1020 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Force-Directed Edge Bundling (FDEB)
[![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
![Example](assets/europe_flights.png)## Installation
`fdeb` can be easily installed through pip using
```
pip install fdeb
```## Usage
```python
edges = ... # (N, 2, 2) -> N edges, each with two endpoints in 2Dfrom fdeb import fdeb
optimized_edges = fdeb(edges)
```## Notes
This package currently implements a numpy-only version of the FDEB algorithm, which has asymptotic complexity O(n^2), making it too slow and memory-hungry for large numbers of graphs.
A numba version of this algorithm is also available at https://github.com/verasativa/python.ForceBundle, however, it also implements the O(n^2) algorithm, so it should (asymptotically) run equally slowly as this package, but is more memory efficient, and perhaps a bit faster on larger graphs.
## A longer example
```python
import numpy as np
import networkx as nxfrom fdeb import fdeb
import matplotlib.pyplot as plt
import matplotlib.collections as collections# Setup embedding and graph
g = nx.karate_club_graph()
x = np.array(list(nx.spring_layout(g).values()))
adj = nx.to_scipy_sparse_array(g).tocoo()# Extract edges from embedding and adjacency matrix
edges = np.stack([x[adj.row], x[adj.col]], axis=1)# Compute FDEB
edges_fdeb = fdeb(edges)# Plot results
fig, ax = plt.subplots(ncols=2, figsize=(8, 4), dpi=150)collection = collections.LineCollection(edges, color="k", alpha=0.05)
ax[0].add_collection(collection)
ax[0].scatter(x[:, 0], x[:, 1], c="tab:red", s=3, zorder=3)collection = collections.LineCollection(edges_fdeb, color="k", alpha=0.05)
ax[1].add_collection(collection)
ax[1].scatter(x[:, 0], x[:, 1], c="tab:red", s=3, zorder=3)
```