dgl.DGLGraph.readonly

DGLGraph.readonly(readonly_state=True)[source]

Set this graph’s readonly state in-place.

Parameters:readonly_state (bool, optional) – New readonly state of the graph, defaults to True.

Examples

>>> G = dgl.DGLGraph()
>>> G.add_nodes(3)
>>> G.add_edge(0, 1)
>>> G.readonly()
>>> try:
>>>     G.add_nodes(5)
>>>     fail = False
>>> except:
>>>     fail = True
>>>
>>> fail
True
>>> G.readonly(False)
>>> G.add_nodes(5)
>>> G.number_of_nodes()
8