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
a4bff0c6
Commit
a4bff0c6
authored
Sep 10, 2008
by
Tiago Peixoto
Browse files
Fix proper handling of properties in graph_draw
parent
1d474dee
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/draw/__init__.py
View file @
a4bff0c6
...
...
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
sys
,
os
import
sys
,
os
,
time
import
matplotlib.cm
import
matplotlib.colors
from
..
core
import
_degree
,
_prop
,
PropertyMap
...
...
@@ -28,7 +28,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
mode
=
"ipsep"
,
penwidth
=
1.0
,
eweight
=
None
,
ewidth
=
None
,
gprops
=
{},
vprops
=
{},
eprops
=
{},
vcolor
=
None
,
ecolor
=
None
,
vcmap
=
matplotlib
.
cm
.
jet
,
vnorm
=
True
,
ecmap
=
matplotlib
.
cm
.
jet
,
enorm
=
True
,
output
=
None
,
output_format
=
None
):
enorm
=
True
,
output
=
None
,
output_format
=
None
,
seed
=
0
):
"""Draw a graph using graphviz."""
if
g
.
is_directed
():
...
...
@@ -39,11 +39,14 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
# main graph properties
gv
.
setv
(
gvg
,
"outputorder"
,
"edgesfirst"
)
gv
.
setv
(
gvg
,
"mode"
,
mode
)
if
overlap
==
"false"
and
layout
==
"neato"
and
mode
==
"ipsep"
:
overlap
=
"ipsep"
if
overlap
:
gv
.
setv
(
gvg
,
"overlap"
,
"true"
)
elif
isinstance
(
overlap
,
str
):
if
overlap
==
False
:
if
layout
==
"neato"
and
mode
==
"ipsep"
:
overlap
=
"ipsep"
else
:
overlap
=
"false"
else
:
overlap
=
"true"
if
isinstance
(
overlap
,
str
):
gv
.
setv
(
gvg
,
"overlap"
,
overlap
)
if
splines
:
gv
.
setv
(
gvg
,
"splines"
,
"true"
)
...
...
@@ -51,9 +54,10 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
gv
.
setv
(
gvg
,
"size"
,
"%f,%f"
%
(
size
[
0
]
/
2.54
,
size
[
0
]
/
2.54
))
# centimeters
if
maxiter
!=
None
:
gv
.
setv
(
gvg
,
"maxiter"
,
str
(
maxiter
))
gv
.
setv
(
gvg
,
"start"
,
str
(
seed
if
seed
>
0
else
time
.
time
()))
# apply all user supplied properties
for
k
,
val
in
v
props
:
for
k
,
val
in
g
props
.
iteritems
()
:
if
isinstance
(
val
,
PropertyMap
):
gv
.
setv
(
gvg
,
k
,
str
(
val
[
g
]))
else
:
...
...
@@ -107,7 +111,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
gv
.
setv
(
n
,
"pin"
,
str
(
pin
))
# apply all user supplied properties
for
k
,
val
in
vprops
:
for
k
,
val
in
vprops
.
iteritems
()
:
if
isinstance
(
val
,
PropertyMap
):
gv
.
setv
(
n
,
k
,
str
(
val
[
v
]))
else
:
...
...
@@ -141,7 +145,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
gv
.
setv
(
ge
,
"penwidth"
,
str
(
ewidth
))
# apply all user supplied properties
for
k
,
v
in
eprops
:
for
k
,
v
in
eprops
.
iteritems
()
:
if
isinstance
(
v
,
PropertyMap
):
gv
.
setv
(
ge
,
k
,
str
(
v
[
e
]))
else
:
...
...
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