':return: SVG representation of a tree.'

def svg(self, nodecolor=u'blue', leafcolor=u'red', funccolor=u'green'):

    fontsize = 12
    hscale = 40
    vscale = 25
    hstart = vstart = 20
    width = max((col for (_, col) in self.coords.values()))
    height = max((row for (row, _) in self.coords.values()))
    result = [(u'<svg    version="1.1"    xmlns="http://www.w3.org/2000/svg"    width="%dem"    height="%dem"    viewBox="%d    %d    %d    %d">' % ((width * 3), (height * 2.5), (- hstart), (- vstart), ((width * hscale) + (3 * hstart)), ((height * vscale) + (3 * vstart))))]
    children = defaultdict(set)
    for n in self.nodes:
        if n:
            children[self.edges[n]].add(n)
    for node in self.nodes:
        if (not children[node]):
            continue
        (y, x) = self.coords[node]
        x *= hscale
        y *= vscale
        x += hstart
        y += (vstart + (fontsize // 2))
        childx = [self.coords[c][1] for c in children[node]]
        xmin = (hstart + (hscale * min(childx)))
        xmax = (hstart + (hscale * max(childx)))
        result.append((u' DCTB <polyline    style="stroke:black;    stroke-width:1;    fill:none;"    points="%g,%g    %g,%g"    />' % (xmin, y, xmax, y)))
        result.append((u' DCTB <polyline    style="stroke:black;    stroke-width:1;    fill:none;"    points="%g,%g    %g,%g"    />' % (x, y, x, (y - (fontsize // 3)))))
    for (child, parent) in self.edges.items():
        (y, _) = self.coords[parent]
        y *= vscale
        y += (vstart + (fontsize // 2))
        (childy, childx) = self.coords[child]
        childx *= hscale
        childy *= vscale
        childx += hstart
        childy += (vstart - fontsize)
        result += [(u' DCTB <polyline    style="stroke:white;    stroke-width:10;    fill:none;"    points="%g,%g    %g,%g"    />' % (childx, childy, childx, (y + 5))), (u' DCTB <polyline    style="stroke:black;    stroke-width:1;    fill:none;"    points="%g,%g    %g,%g"    />' % (childx, childy, childx, y))]
    for (n, (row, column)) in self.coords.items():
        node = self.nodes[n]
        x = ((column * hscale) + hstart)
        y = ((row * vscale) + vstart)
        if (n in self.highlight):
            color = (nodecolor if isinstance(node, Tree) else leafcolor)
            if (isinstance(node, Tree) and node.label().startswith(u'-')):
                color = funccolor
        else:
            color = u'black'
        result += [(u' DCTB <text    style="text-anchor:    middle;    fill:    %s;    font-size:    %dpx;"    x="%g"    y="%g">%s</text>' % (color, fontsize, x, y, escape((node.label() if isinstance(node, Tree) else node))))]
    result += [u'</svg>']
    return u'\n'.join(result)
