Skip to content

Straightening edges can introduce new edge crossings #60

Description

@mhdirkse

See picture below, the area in the purple circle:

Image

I inserted the following Mermaid code in the playground:

flowchart
	d2e2("<b>Test1</b><br/>JavaListener"):::normal
	d2e12("<b>InputValidator</b>"):::normal
	d2e73("<b>resolveError</b><br/>Text2XmlPipe"):::errorOutline
	d2e17ERROR("<b>OutputWrapper</b>"):::normal
	d2e12ERROR("<b>OutputValidator</b>"):::normal
	d2e7("<b>error</b>"):::normal
	d2e17EXIT("<b>OutputWrapper</b>"):::normal
	d2e12EXIT("<b>OutputValidator</b>"):::normal
	d2e6("<b>success</b>"):::normal
	d2e16("<b>InputWrapper</b>"):::normal
	d2e18("<b>TestXmlIfWithForwards</b><br/>XmlIf"):::normal
	d2e24("<b>TestXmlIfWithAttributes</b><br/>XmlIf"):::normal
	d2e32("<b>TestXmlSwitchWithForwards</b><br/>XmlSwitch"):::normal
	d2e61("<b>TestCompareInteger</b><br/>CompareIntegerPipe"):::normal
	d2e38("<b>TestXmlSwitchWithAttributes</b><br/>XmlSwitch"):::normal
	d2e26("<b>TestXmlIfWithBoth</b><br/>XmlIf"):::normal
	d2e40("<b>TestXmlSwitchWithBoth</b><br/>XmlSwitch"):::normal
	d2e47("<b>TestXmlSwitchWithNone</b><br/>XmlSwitch"):::normal
	d2e49("<b>TestCompareString</b><br/>TestCompareString"):::normal
	classDef normal fill:#fff,stroke-width:4px,stroke:#8bc34a;
	classDef errorOutline fill:#fff,stroke-width:4px,stroke:#ec4758;
	d2e2 --> |success| d2e12
	d2e12 --> |exception| d2e73
	d2e12 --> |success| d2e16
	d2e73 --> |exception| d2e17ERROR
	d2e73 --> |success| d2e17EXIT
	d2e17ERROR --> |success| d2e12ERROR
	d2e12ERROR --> |exception| d2e73
	d2e12ERROR --> |success<br/>ERROR| d2e7
	d2e17EXIT --> |success| d2e12EXIT
	d2e12EXIT --> |exception| d2e73
	d2e12EXIT --> |success<br/>EXIT| d2e6
	d2e16 --> |success| d2e18
	d2e18 --> |then| d2e24
	d2e18 --> |else| d2e26
	d2e24 --> |then| d2e32
	d2e24 --> |else| d2e38
	d2e32 --> |option1| d2e61
	d2e32 --> |option2| d2e17EXIT
	d2e32 --> |exception| d2e17ERROR
	d2e61 --> |lessthan<br/>greaterthan<br/>equals<br/>success| d2e17EXIT
	d2e38 --> |exception<br/>notFoundForwardName| d2e17ERROR
	d2e38 --> |emptyForwardName| d2e61
	d2e26 --> |then| d2e40
	d2e26 --> |else| d2e49
	d2e40 --> |option1| d2e17EXIT
	d2e40 --> |option2| d2e47
	d2e40 --> |exception<br/>emptyForwardName| d2e17ERROR
	d2e40 --> |notFoundForwardName| d2e49
	d2e47 --> |exception| d2e17ERROR
	d2e49 --> |lessthan<br/>greaterthan<br/>equals<br/>success| d2e17EXIT
	d2e49 --> |exception| d2e17ERROR
	linkStyle 0,2,5,7,8,10,11,12,13,14,15,16,17,19,20,21,22,25,26,27,28,29,30,32,33,35,36,37,38 stroke:#8bc34a,stroke-width:3px,fill:none;
	linkStyle 1,3,4,6,9,18,23,24,31,34,39 stroke:#ec4758,stroke-width:3px,fill:none;

Then I used the buttons shown below to reduce the number of crossings:

Image

This is similar to minimizing the number of crossings automatically, but that algorithm makes arbitrary choices. The first picture of this issue was obtained by making different choices that could have been used by the algorithm. After placing the nodes and the intermediate nodes, the edges make many bends because the intermediate nodes are not placed on a straight line. The algorithm then tries to remove intermediate nodes and draw straight lines between the remaining (intermediate) nodes. You see that an extra crossing was produced by this process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions