Hi,
you can create those preset with a commandData sure.
When you add the graph to your node material it will call the function you defined in maxon::nodes::NODESPACE::CREATEMATERIALGRAPHFUNC See Proving Default Graph Setup for more information. So be sure to remove the nodes added by this function if they are not needed.
You must create a NodeMaterial, insert it in the document, add the graph for the right nodespace and retrieve the graph itself (by first retrieving the nimbusref). We got an example on this page: Reading and Modifying Node
This page also contains an introduction to Transaction. maxon::GraphModelInterface::BeginTransaction must be used if you want to modify the graph. You can than Commit your changes, which will ensure the graph is in a correct state. You can have a look a nodespace_impl.cpp, you will find the function CreateMaterialGraphDefaultSetup. remarque: this function doesn't need transactions to modify the graph.
In this handbook, we are using transaction to modify some port's value inside a graph. With both examples, you will understand how to add nodes, connect them, and sets values.
Cheers,
Manuel.