Moving existing node in a document to a subgraph in the document , using code

I want to add a node to subgraph. Here, node and subgraph are already there on the document. I want to move a node to subgraph , using code. I can move the node by draaging and shift+dropping. But I want to do it by program. subgraph.add method adds the node again on the document but this methods require node should not be added to the document.
Is there any method to do so?

Thanks and regards,

I solved the problem by removing node from the document and then using subgraph.add(node). This works but if there any other method to do above. Please let me know.


Look at MakeSubGraph in SubGraphApp.

Thank you very much Jakeā€¦