8000 Deep Copy · Issue #13 · heimdalr/dag · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Deep Copy #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aidan-mundy opened this issue Nov 16, 2021 · 1 comment
Closed

Deep Copy #13

aidan-mundy opened this issue Nov 16, 2021 · 1 comment

Comments

@aidan-mundy
Copy link

Deep copy functionality would be nice to have built in, to have a second copy of the existing graph for further manipulation or recursive operations and such.

@sebogh
Copy link
Collaborator
sebogh commented Jan 5, 2022

@aidan-mundy the latest master (354d4ae) implements a Copy() method:

dag/dag.go

Lines 868 to 884 in 354d4ae

// Copy returns a copy of the DAG.
func (d *DAG) Copy() (newDAG *DAG, err error) {
// create a new dag
newDAG = NewDAG()
// create a map of visited vertices
visited := make(map[interface{}]string)
// add all roots and their descendants to the new DAG
for _, root := range d.GetRoots() {
if _, err = d.getRelativesGraphRec(root, newDAG, visited, false); err != nil {
return
}
}
return
}

Could you try? Thx.

@sebogh sebogh closed this as completed Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0