NetworkX

Previous topic

networkx.classes.function.get_edge_attributes

Next topic

networkx.classes.function.is_frozen

networkx.classes.function.freeze

networkx.classes.function.freeze(G)

Modify graph to prevent addition of nodes or edges.

Parameters :

G : graph

A NetworkX graph

See also

is_frozen

Notes

This does not prevent modification of edge data.

To “unfreeze” a graph you must make a copy.

Examples

>>> G=nx.Graph()
>>> G.add_path([0,1,2,3])
>>> G=nx.freeze(G)
>>> try:
...    G.add_edge(4,5)
... except nx.NetworkXError as e:
...    print(str(e))
Frozen graph can't be modified