Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
da569528
Commit
da569528
authored
Aug 19, 2015
by
Tiago Peixoto
Browse files
Implement __copy__ and __deepcopy__ for Graph and PropertyMap
parent
f2acf0b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
da569528
...
...
@@ -518,13 +518,29 @@ class PropertyMap(object):
vals
)
def
copy
(
self
,
value_type
=
None
):
"""Return a copy of the property map. If ``value_type`` is specified,
the
value type is converted to the chosen type."""
"""Return a copy of the property map. If ``value_type`` is specified,
the
value type is converted to the chosen type."""
return
self
.
get_graph
().
copy_property
(
self
,
value_type
=
value_type
)
def
__copy__
(
self
):
return
self
.
copy
()
def
__deepcopy__
(
self
,
memo
):
if
self
.
value_type
()
!=
"python::object"
:
return
self
.
copy
()
else
:
pmap
=
self
.
copy
()
g
=
self
.
get_graph
()
if
self
.
key_type
()
==
"g"
:
iters
=
[
g
]
elif
self
.
key_type
()
==
"v"
:
iters
=
g
.
vertices
()
else
:
iters
=
g
.
edges
()
for
v
in
iters
:
pmap
[
v
]
=
copy
.
deepcopy
(
self
[
v
],
memo
)
return
pmap
def
get_graph
(
self
):
"""Get the graph class to which the map refers."""
g
=
self
.
__g
()
...
...
@@ -1441,6 +1457,9 @@ class Graph(object):
def
__copy__
(
self
):
return
self
.
copy
()
def
__deepcopy__
(
self
,
memo
):
return
self
.
copy
()
def
__repr__
(
self
):
# provide more useful information
d
=
"directed"
if
self
.
is_directed
()
else
"undirected"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment