C# to PHP : Graphs