working on graph algorithm php implementation