Impossible to answer this question, just a few hints.
you must know:
- gps position of each graves.
- make a map of each roads in cemetery.
- make a map of each pedestrian alley.
- establish walking rules.
after that I guess you must set the rules for a shortest path algorithm.
Shortest path problem - Wikipedia[
^]
Dijkstra's algorithm - Wikipedia[
^]