Commit a4bff0c6 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix proper handling of properties in graph_draw

parent 1d474dee
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys,os import sys,os,time
import matplotlib.cm import matplotlib.cm
import matplotlib.colors import matplotlib.colors
from .. core import _degree, _prop, PropertyMap from .. core import _degree, _prop, PropertyMap
...@@ -28,7 +28,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato", ...@@ -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={}, mode="ipsep", penwidth=1.0, eweight=None, ewidth=None, gprops={},
vprops={}, eprops={}, vcolor=None, ecolor=None, vprops={}, eprops={}, vcolor=None, ecolor=None,
vcmap=matplotlib.cm.jet, vnorm=True, ecmap=matplotlib.cm.jet, 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.""" """Draw a graph using graphviz."""
if g.is_directed(): if g.is_directed():
...@@ -39,11 +39,14 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato", ...@@ -39,11 +39,14 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
# main graph properties # main graph properties
gv.setv(gvg,"outputorder", "edgesfirst") gv.setv(gvg,"outputorder", "edgesfirst")
gv.setv(gvg,"mode", mode) gv.setv(gvg,"mode", mode)
if overlap == "false" and layout == "neato" and mode == "ipsep": if overlap == False:
if layout == "neato" and mode == "ipsep":
overlap = "ipsep" overlap = "ipsep"
if overlap: else:
gv.setv(gvg,"overlap", "true") overlap = "false"
elif isinstance(overlap,str): else:
overlap = "true"
if isinstance(overlap,str):
gv.setv(gvg,"overlap", overlap) gv.setv(gvg,"overlap", overlap)
if splines: if splines:
gv.setv(gvg,"splines", "true") gv.setv(gvg,"splines", "true")
...@@ -51,9 +54,10 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato", ...@@ -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 gv.setv(gvg,"size", "%f,%f" % (size[0]/2.54,size[0]/2.54)) # centimeters
if maxiter != None: if maxiter != None:
gv.setv(gvg,"maxiter", str(maxiter)) gv.setv(gvg,"maxiter", str(maxiter))
gv.setv(gvg,"start", str(seed if seed > 0 else time.time()))
# apply all user supplied properties # apply all user supplied properties
for k,val in vprops: for k,val in gprops.iteritems():
if isinstance(val, PropertyMap): if isinstance(val, PropertyMap):
gv.setv(gvg, k, str(val[g])) gv.setv(gvg, k, str(val[g]))
else: else:
...@@ -107,7 +111,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato", ...@@ -107,7 +111,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
gv.setv(n, "pin", str(pin)) gv.setv(n, "pin", str(pin))
# apply all user supplied properties # apply all user supplied properties
for k,val in vprops: for k,val in vprops.iteritems():
if isinstance(val, PropertyMap): if isinstance(val, PropertyMap):
gv.setv(n, k, str(val[v])) gv.setv(n, k, str(val[v]))
else: else:
...@@ -141,7 +145,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato", ...@@ -141,7 +145,7 @@ def graph_draw(g, pos=None, size=(15,15), pin=False, layout="neato",
gv.setv(ge, "penwidth", str(ewidth)) gv.setv(ge, "penwidth", str(ewidth))
# apply all user supplied properties # apply all user supplied properties
for k,v in eprops: for k,v in eprops.iteritems():
if isinstance(v, PropertyMap): if isinstance(v, PropertyMap):
gv.setv(ge, k, str(v[e])) gv.setv(ge, k, str(v[e]))
else: else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment