based logic for graph words.