a planar graph is cleaned with operations that utilize x y location

Duplicate Nodes in Space

When two nodes occupy the same space they will be merged into one

 nodes,  edges

Epsilon is the radius around a point where merging occurs. It's a fraction of the size of the canvas. A larger number will merge across a further distance.


Fragmenting edges will chop them at their edge crossings


This will give you the crossing locations without fragmenting. It returns an EdgeIntersection object.

The SVG on the right has been fragmented

Collinear Planar Graph Edges

Collinear nodes can be removed, the two edges on either side merged into one.


Removing edges will remove their nodes, and so will nodes left behind between 2 collinear lines be removed as well.

Intersection of Two Edges

Collinear lines at certain angles is a good place to test the robustness of the intersection algorithm