MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / Node

Class Node

graphs/deep_clone_graph.py:17–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16@dataclass
17class Node:
18 value: int = 0
19 neighbors: list["Node"] | None = None
20
21 def __post_init__(self) -> None:
22 """
23 >>> Node(3).neighbors
24 []
25 """
26 self.neighbors = self.neighbors or []
27
28 def __hash__(self) -> int:
29 """
30 >>> hash(Node(3)) != 0
31 True
32 """
33 return id(self)
34
35
36def clone_graph(node: Node | None) -> Node | None:

Callers 1

clone_graphFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected