clean-pslg
Version:
Remove self intersections, t-junctions and duplicate edges/vertices from a planar straight line graph
30 lines (25 loc) • 557 B
JavaScript
var cleanupPSLG = require('../clean-pslg')
//Create a planar straight line graph with many degenerate crossings
var points = [
[ 0.25, 0.5 ],
[ 0.75, 0.5 ],
[ 0.5, 0.25 ],
[ 0.5, 0.75 ],
[ 0.25, 0.25 ],
[ 0.75, 0.75 ],
[ 0.25, 0.75 ],
[ 0.75, 0.25 ]
]
//These are the edges of the graph
var edges = [
[],
[],
[],
[]
]
//Run clean up on the graph
if(cleanupPSLG(points, edges)) {
console.log('removed degeneracies from graph')
}
console.log('points = \n', points)
console.log('edges = \n', edges)