An orthogonal layout algorithm, using TSM approach
Project description
Introduction
An implementation of orthogonal drawing algorithm in Python
Main idea comes from A Generic Framework for the Topology-Shape-Metrics Based Layout
How to run code
Install requirements
pip install -r requirements.txt
Usage
# in root dir
import networkx as nx
from tsmpy import TSM
from matplotlib import pyplot as plt
G = nx.Graph(nx.read_gml("test/inputs/case2.gml"))
# initial layout, it will be converted to an embedding
pos = {node: eval(node) for node in G}
# pos is an optional, if pos is None, embedding will be given by nx.check_planarity
# use linear programming to solve minimum cost flow program
tsm = TSM(G, pos)
# or use nx.min_cost_flow to solve minimum cost flow program
# it is faster but produces worse result
# tsm = TSM(G, pos, uselp=False)
tsm.display()
plt.savefig("test/outputs/case2.lp.svg")
plt.close()
Example
| case1 | case2 |
|---|---|
| bend case | grid case |
|---|---|
Run tests
# show help
python test.py -h
# run all tests
python test.py
# run all tests in TestGML
python test.py TestGML
Playground
Try editing original case2 graph with yed
Requirements for input graph
- Planar
- Connected
- Max node degree is no more than 4
- No selfloop
Features
- Using linear programing to solve minimum-cost flow problem, to reduce number of bends
TODO
- Cleaner code
- More comments
- Fix overlay
- Support node degree > 4
- Support cut-edges
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tsmpy-0.9.3.tar.gz
(12.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tsmpy-0.9.3-py3-none-any.whl
(23.9 kB
view details)
File details
Details for the file tsmpy-0.9.3.tar.gz.
File metadata
- Download URL: tsmpy-0.9.3.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df0b54cc0ba46e2041bb664f90488f82092211dfd32acc9935393aa6ed0f9ef9
|
|
| MD5 |
e57eaca3cfa7207fd221a2c3d75f41ca
|
|
| BLAKE2b-256 |
27e907a31ccf4a59e2952d16bb92e3c8c2c4755dd43043c6b029730a6d4df558
|
File details
Details for the file tsmpy-0.9.3-py3-none-any.whl.
File metadata
- Download URL: tsmpy-0.9.3-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97932a3bcd1ea9366f7fbd531c6031678c7b3c6f72046c041e052b4c92fe77df
|
|
| MD5 |
91b5505cc609d6d7903eb8cb899372ae
|
|
| BLAKE2b-256 |
ba9833cffdf875536a9075093902b98c2dc0bf063b5f11c2712aab26175381b1
|