Skip to main content

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
case1 case2
bend case grid case
bend grid

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

Metadata

Release files for tsmpy 0.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsmpy 0.9.3
File Size Uploaded Provenance Actions
tsmpy-0.9.3.tar.gz 12.9 kB Without provenance Details for tsmpy-0.9.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tsmpy 0.9.3
File Interpreter ABI Platform Actions
tsmpy-0.9.3-py3-none-any.whl Python 3 none any Details for tsmpy-0.9.3-py3-none-any.whl

Total release size: 36.7 kB

Release files / tsmpy-0.9.3.tar.gz

Download URL tsmpy-0.9.3.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
df0b54cc0ba46e2041bb664f90488f82092211dfd32acc9935393aa6ed0f9ef9
BLAKE2b-256 checksum
How to use checksums
27e907a31ccf4a59e2952d16bb92e3c8c2c4755dd43043c6b029730a6d4df558
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / tsmpy-0.9.3-py3-none-any.whl

Download URL tsmpy-0.9.3-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97932a3bcd1ea9366f7fbd531c6031678c7b3c6f72046c041e052b4c92fe77df
BLAKE2b-256 checksum
How to use checksums
ba9833cffdf875536a9075093902b98c2dc0bf063b5f11c2712aab26175381b1
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for tsmpy 0.9.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page