added code for graph search