Speed up xPx and xPO queries

Vertices and edges are search for by properties using Graph#has and
Graph#query methods.