BerGeo/h2/mbc.py

21 lines
487 B
Python
Raw Normal View History

2018-09-24 13:27:08 +00:00
import statistics
from collections import namedtuple
from typing import List, Set
Point = namedtuple('Point', 'x y')
def mbc_ch(points: Set[Point]):
# Find the point with median x-coordinate, and partition the points on this point
pm = statistics.median_high(points)
pl = {point
for point in points
if point.x < pm.x}
pr = {point
for point in points
if point.x >= pm.x}
# Find the bridge over the vertical line in pm