Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilivans/subway-map
Force-directed graph drawing algorithm for subway map layout
https://github.com/ilivans/subway-map
graph
Last synced: 5 days ago
JSON representation
Force-directed graph drawing algorithm for subway map layout
- Host: GitHub
- URL: https://github.com/ilivans/subway-map
- Owner: ilivans
- License: mit
- Created: 2018-10-26T02:31:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-30T01:32:34.000Z (about 6 years ago)
- Last Synced: 2024-11-01T13:36:22.615Z (7 days ago)
- Topics: graph
- Language: Python
- Homepage:
- Size: 682 KB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - ilivans/subway-map - Force-directed graph drawing algorithm for subway map layout (others)
README
## Subway map layout
Implementation of force-directed graph drawing algorithm for subway map layout.Assignment of Data Visualization course, MIPT, 2018.
#### Requirements
Python 3.5+
`pip3 install -r requirements.txt`
#### Related work
The Metro Map Layout Problem, Seok-Hee Hong et al. https://pdfs.semanticscholar.org/1a70/e421477293d06d2d6e60524b42f773fe6e8a.pdf
#### Algorithm
Fruchterman–Reingold algorithm source: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.13.8444&rep=rep1&type=pdf
It's an iterative algorithm which simulates repulsive forces between all nodes and attractive forces between adjacent nodes.
Implementation is at `layout.py`
#### Data
Moscow and Saint Petersburg subway maps were used for experiments.
To get subway map with geo positions hh.ru API was used: https://api.hh.ru/metro/1.
#### Experiments
For simplicity interconnected stations are considered as one for algirithm as well as for visualization (those are colored black).
Stations and lines names are not drawn because it's another complex problem to locate them optimally and labels will distract from graph layout quality estimation.
For all experiments geo position of stations were used as initial position of graph nodes.
In the final script 2 variants of algorithm application are presented:
* pure one
* with fixed position of terminal stations![](images/spb.png)
![](images/moscow.png)It can be seen that algorithm helps to make lines straighter and edges length more uniform which is important for map readability. The results are far from perfect though as there are multiple criteria of good subway layout aren't met.
To reproduce the results run `main.py`
#### Failed experiments
Also few modifications of the algorithm with additional attractive forces were tried:
* to keep edges direction close to corresponding line direction
* to keep edges direction close to horizontal, vertical and 45 degrees
* to keep nodes close to their initial positionsThose didn't result in good layouts thought. The code is at `layout_custom.py`.