Add fix for inheritance problem.

Add an extra argument for the add_subgraph method that allows one to
define which class will be used for the new subgraph. If no class is
given it assumes same as self.