MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / graphDeepCopy

Function graphDeepCopy

kotlin/Graphs/GraphDeepCopy.kt:11–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9*/
10
11fun graphDeepCopy(node: GraphNode?): GraphNode? {
12 if (node == null) {
13 return null
14 }
15 return dfs(node, mutableMapOf())
16}
17
18fun dfs(node: GraphNode, cloneMap: MutableMap<GraphNode, GraphNode>): GraphNode {
19 // If this node was already cloned, then return this previously

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected