graphs.deep_clone_graph¶
LeetCode 133. Clone Graph https://leetcode.com/problems/clone-graph/
Given a reference of a node in a connected undirected graph.
Return a deep copy (clone) of the graph.
Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors.
Classes¶
Functions¶
|
This function returns a clone of a connected undirected graph. |
Module Contents¶
- class graphs.deep_clone_graph.Node¶
- __hash__() int ¶
>>> hash(Node(3)) != 0 True
- __post_init__() None ¶
>>> Node(3).neighbors []
- value: int = 0¶
- graphs.deep_clone_graph.clone_graph(node: Node | None) Node | None ¶
This function returns a clone of a connected undirected graph. >>> clone_graph(Node(1)) Node(value=1, neighbors=[]) >>> clone_graph(Node(1, [Node(2)])) Node(value=1, neighbors=[Node(value=2, neighbors=[])]) >>> clone_graph(None) is None True