<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_subgraph(self, sgraph):
 """Adds an subgraph object to the graph. It takes a subgraph object as its only argument and returns None. """


        if not isinstance(sgraph, Subgraph) and not isinstance(sgraph, Cluster):
            raise TypeError('add_subgraph() received a non subgraph class object:' + str(sgraph))
            
        if self.obj_dict['subgraphs'].has_key(sgraph.get_name()):
        
            sgraph_list = self.obj_dict['subgraphs'][ sgraph.get_name() ]
            sgraph_list.append( sgraph.obj_dict )
                
        else:
            self.obj_dict['subgraphs'][ sgraph.get_name() ] = [ sgraph.obj_dict ]
         
        sgraph.set_sequence( self.get_next_sequence_number() )
        
        sgraph.set_parent_graph( self.get_parent_graph() )