np-guard / netpol-analyzer

A Golang library for analyzing k8s connectivity-configuration resources (a.k.a. network policies)
Apache License 2.0
9 stars 2 forks source link

Avoid collisions of ingress-egress edges in the output dot graph #375

Closed tanyaveksler closed 1 month ago

tanyaveksler commented 1 month ago

When there are edges in two directions between two nodes, sometimes the text on one edge is above the text o the other edge. See https://github.com/np-guard/netpol-analyzer/blob/main/test_outputs/diff/diff_betwe[…]ol-diff-example-minimal_and_netpol-analysis-example-minimal.dot](https://github.com/np-guard/netpol-analyzer/blob/main/test_outputs/diff/diff_between_netpol-diff-example-minimal_and_netpol-analysis-example-minimal.dot)

Avoid this situation by giving different weights to those edges. The simplest solution would be adding weight to every edge, where the sorting order between srcand dstpeers of the edge defines the weight. More delicate solution would be adding weight to the relevant edges only, i.e., to the pairs of edges connecting the same pair of peers.