CLEAN

Cleaning a planar graph will ensure there are no duplicate or circular edges, just like a regular graph, but also perform additional 2D-related operations, like resolve 2 crossed edges.

graph.clean()

Duplicate Nodes in Space

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

 nodes,  edges

The process by which 2 nodes are said to occupy the same space is heavily dependent on the epsilon (ε) value which declares two numbers to be the same. A larger epsilon will merge points across a greater distance.

Both graphs have been cleaned, the one on the right was given a larger epsilon.

graph.cleanDuplicateNodes(epsilon)

Epsilon (ε) is the tiny space deep in the floating point number past the decimal point.

Fragment

Fragmenting edges will chop them at their edge crossings.

The graph on the right has been fragmented. The longer lines have been split at their crossings.

graph.fragment()

Collinear Planar Graph Edges

Collinear nodes can be removed, the two edges on either side merged into one, disappearing the point which once divided the edge.

graph.removeEdge(edge)

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

Intersection of Two Edges

Mathematically speaking, parallel lines have zero points of intersection and collinear lines have infinite. However in this library collinear lines will register to have zero points of intersection.

The epsilon has been increased to magnify the moment that the lines become parallel.