Name for dgl.DGLGraph

Can the class dgl.DGLGraph also support a name for each graph?

My code looks something like this. For my implementation it would be convenient if I could have a name for each graph. Is there a way to store the graph name on the dgl.DGLGraph object itself? I guess the best shot is to have a parallel list sharing the same index as the list graphs.

def __init__( self, mode='train' ):
		self.graphPaths = []
		self.graphs = []
		for designPath in Path( Path.cwd() ).iterdir():
			if designPath.is_dir():
				self.graphPaths.append( designPath )
		self.mode = mode
		super().__init__(name='mydata_from_yosys_'+mode)

def process( self ):
		for path in self.graphPaths:
			graph = self._process_single( path )
			self.graphs.append( graph )

Yes, having a parallel name list is a reasonable workaround.

Is there any specific consideration for attaching names to graphs? I think it’s unnecessary to save the name as a property in DGLGraph if the name does not participate in later computation.

I would say it is dependent on the implementation. I am working with logic circuits, and they have a name each of them, such as c17, c432, GCD, AES, and it would be nice to keep track of their train and validation accuracies independently.

Also, I would like to know if there is a way to add the attribute to the object myself, such as is done with the dataset object.

In this case, I think maintaining a name list or a name-to-graph_id mapping is enough.

It may be unnecessary to add the name as an attribute to the graph object. But you can always do that by directly assigning it to the graph after creating it by g.name = 'c17', or by inheriting the DGLGraph class to add name attribute in the __init__ method.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.