PREFIX rdf: PREFIX rdfs: PREFIX foaf: SELECT ?X ?Y { # Closer - but people can make statements about two other people. GRAPH ?g1 { ?x1 foaf:knows ?y1 . # Use mbox to identify people. ?x1 foaf:mbox ?mbox_x . ?y1 foaf:mbox ?mbox_y . } GRAPH ?g2 { # Use mbox to find the node representing a person. ?x2 foaf:mbox ?mbox_x . ?y2 foaf:mbox ?mbox_y . ?y2 foaf:knows ?x2 . # x and y reversed } GRAPH ?g2 { ?x2 foaf:name ?X . ?y2 foaf:name ?Y . FILTER(?X < ?Y) } }