private void writeSpineToGraphviz(BufferedWriter b, SpinalNode current,
            boolean isRoot, int start, int end, boolean includeSpans, boolean beanPoleStyle)
            throws IOException {

        checkCompletion();
        
        int n = current.getElemTree().getNumber();

        if (start != -1 && end != -1) {
            if (n < start || n > end) throw new IllegalArgumentException();
        }

        // create a graphviz node for the current spinal node
        String currentNode = current.getGraphvizNodeID();
        b.write(currentNode + "[label=\"" + current.getLabel());
        
        if (includeSpans) {
            String thespan = this.getSpan().toString();
            if (!isRoot) {
                thespan = "";
            }
            b.write(" " + thespan);
        }
        
        if (!current.getType().equals(SpinalNode.ANCHOR)) {
            b.write(current.getType());
        }
        b.write("\" ");

        // uncomment the next line to make the root of the spine stand out
        //if (isRoot) b.write("style=bold");

        b.write("];");
        b.newLine();
        
        // create edges from the anchor SpinalNode to the actual
        // lexical anchor, which is represented by the
        // graphviz node ID of the ElemTree itself (i.e. this)

        if (current.getType().equals(SpinalNode.ANCHOR)) {
            b.write(currentNode 
                    + " -> " 
                    + this.getGraphvizNodeID() 
                    + "[style=bold arrowhead=none];");
            b.newLine();
        }

        // create edges from the current node to its children (if any)

        // children are never drawn emphasized (only the root of the
        // present spine is)

        SpinalNode[] children = current.getChildren();

        for (int i = 0; i < children.length; i++) {
            writeSpineToGraphviz(b, children[i], false, start, end, includeSpans, beanPoleStyle);

            // add edges to children
            b.write(currentNode 
                    + " -> " 
                    + children[i].getGraphvizNodeID() 
                    + "[style=bold arrowhead=none];");
            b.newLine();
        }

    }