Find edge ids by pairs or path