Similar Items: Graph Logics with Rational Relations