Actually, CHYOA stories are by default trees, not graphs, and you would be looking for the longest path, not the shortest. Each chapter can store a value representing the height of the subtree rooted at that chapter, and when a new chapter is added or deleted, increment or decrement that value...