Computing the visibility graphs of n line segments in O(nn) time