The function `GraphMatfun(T,g)` should act as an instantiation of a new object and therefore also make a deepcopy of all elements of `g`.