Research code to compute broken lines and greedy elements