the crossing number is implemented (perhaps quite poorly, or not) in this project to try to demonstrate how this works. http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm#Crossing%20Number