Speed up xPx and xPO queries

Vertices and edges are searched for by properties using
Graph#get{Vertices,Edges}(key, value) and Graph#query methods.