working C code to get edge's lenghts