Added optional C++/MEX implementation for some graph function