You need to walk through the original graph and build a copy as you go. For each node you visit, create a new node with the same value. Then recursively visit each neighbor and connect the copies.
The tricky part: graphs can have cycles and shared neighbors. If nodes and both connect to node , you must reuse the same copied node for both. You cannot create separate copies. Your strategy needs a way to remember which nodes you have already copied.