termgraph
termgraph copied to clipboard
Better ordering of the Edges
Currently the Edges are not really ordered in a good or consistent way, resulting in some unnecessary crossings when there was a possible layout that is both cleaner and maybe more compact.
Ideas
Sort by connection distance
A simple first idea, would be to sort the dummies/edges by the distance to the layer their target node is actually in. This would automatically create multiple "layers" of nodes/edges where the outer ones are going further down the Graph, hopefully without crossing over others in the process. This would also mean that we would need to keep the same ordering of dummy nodes in the following layers to make sure there are no extra crossings there.
Example
Bad
(0)
|
+----+---+--+
| | | |
V V | |
(1) (2) | |
| | | |
+----+ | |
| | |
+--------+--+
| |
| +----+
| |
V |
(3) |
| |
+---+
|
V
(4)
Good
(0)
|
+----+---+--+
| | | |
V V | |
(2) (1) | |
| | | |
+----+ | |
| | |
+--------+ |
| |
| +-------+
| |
V |
(3) |
| |
+---+
|
V
(4)
We should also sort the horizontals based on similiar criteria to avoid unnecessary cross overs caused by two horizontals being in the wrong order, which can also be seen in the example of the original Issue.