def METHOD_NAME(self, nodes, elements):
    segments = {}  # key=eid,
    lengths = {}
    for eid, e in elements.items():
        a = tuple(sorted([e[0], e[1]]))  # segments of e
        b = tuple(sorted([e[1], e[2]]))
        c = tuple(sorted([e[2], e[0]]))
        if a in segments:
            segments[a].append(eid)
        else:
            segments[a] = [eid]
            lengths[a] = nodes[a[1]] - nodes[a[0]]
        if b in segments:
            segments[b].append(eid)
        else:
            segments[b] = [eid]
            lengths[b] = nodes[b[1]] - nodes[b[0]]
        if c in segments:
            segments[c].append(eid)
        else:
            segments[c] = [eid]
            lengths[c] = nodes[c[1]] - nodes[c[0]]
    return segments, lengths