compute triads given edges