Simple graph data structure and algorithms