0

I have a pygraph data structure, which I want to modify. I want to perform the following operations:

  1. Create a copy of the existing pygraph
  2. Modify the nodes in the copy, by walking the tree and changing the node attributes

I am unable to find in the documentation/code how to do these operations. Is it possible? How?

blueFast
  • 41,341
  • 63
  • 198
  • 344

1 Answers1

0

Copying:

To copy a structure in python you need to make use of the copy module

from copy import deepcopy
copy_graph = deepcopy(original_graph)

Traversing

There is an example on how to traverse the graph:

from pygraph.algorithms.searching import depth_first_search
st, pre, post = depth_first_search(copy_graph)
synthomat
  • 774
  • 5
  • 11