(self, graph, startNode=0)
return count
Write a graph to the pydot Graph instance

        :param graph: the pydot Graph instance
        :param startNode: used to plot more than one individual
Write a graph to the pydot Graph instance
Write a graph to the pydot Graph instance
def writeDotGraph(self, graph, startNode=0):
        """ Write a graph to the pydot Graph instance

        :param graph: the pydot Graph instance
        :param startNode: used to plot more than one individual
        """
        if not HAVE_PYDOT:
            print "You must install Pydot to use this feature !"
            return

        count = startNode
        node_stack = []
        nodes_dict = {}
        import __main__ as main_module

        for i in xrange(len(self.nodes_list)):
            newnode = pydot.Node(str(count), style="filled")
            count += 1

            if self.nodes_list[i].getType() == Consts.nodeType["TERMINAL"]:
                newnode.set_color("lightblue2")
            else:
                newnode.set_color("goldenrod2")

            if self.nodes_list[i].getType() == Consts.nodeType["NONTERMINAL"]:
                func = getattr(main_module, self.nodes_list[i].getData())

                if hasattr(func, "shape"):
                    newnode.set_shape(func.shape)

                if hasattr(func, "representation"):
                    newnode.set_label(func.representation)
                else:
                    newnode.set_label(self.nodes_list[i].getData())
                if hasattr(func, "color"):
                    newnode.set_color(func.color)

            else:
                newnode.set_label(self.nodes_list[i].getData())

            nodes_dict.update({self.nodes_list[i]: newnode})
            graph.add_node(newnode)

        node_stack.append(self.getRoot())
        while len(node_stack) > 0:
            tmp = node_stack.pop()

            parent = tmp.getParent()
            if parent is not None:
                parent_node = nodes_dict[parent]
                child_node = nodes_dict[tmp]

                newedge = pydot.Edge(parent_node, child_node)
                graph.add_edge(newedge)

            rev_childs = tmp.getChilds()[:]
            rev_childs.reverse()
            node_stack.extend(rev_childs)

        return count
def writeDotGraph ( self , graph , startNode = 0 ) : if not HAVE_PYDOT : print "You must install Pydot to use this feature !" return count = startNode node_stack = [ ] nodes_dict = { } import __main__ as main_module for i in xrange ( len ( self . nodes_list ) ) : newnode = pydot . Node ( str ( count ) , style = "filled" ) count += 1 if self . nodes_list [ i ] . getType ( ) == Consts . nodeType [ "TERMINAL" ] : newnode . set_color ( "lightblue2" ) else : newnode . set_color ( "goldenrod2" ) if self . nodes_list [ i ] . getType ( ) == Consts . nodeType [ "NONTERMINAL" ] : func = getattr ( main_module , self . nodes_list [ i ] . getData ( ) ) if hasattr ( func , "shape" ) : newnode . set_shape ( func . shape ) if hasattr ( func , "representation" ) : newnode . set_label ( func . representation ) else : newnode . set_label ( self . nodes_list [ i ] . getData ( ) ) if hasattr ( func , "color" ) : newnode . set_color ( func . color ) else : newnode . set_label ( self . nodes_list [ i ] . getData ( ) ) nodes_dict . update ( { self . nodes_list [ i ] : newnode } ) graph . add_node ( newnode ) node_stack . append ( self . getRoot ( ) ) while len ( node_stack ) > 0 : tmp = node_stack . pop ( ) parent = tmp . getParent ( ) if parent is not None : parent_node = nodes_dict [ parent ] child_node = nodes_dict [ tmp ] newedge = pydot . Edge ( parent_node , child_node ) graph . add_edge ( newedge ) rev_childs = tmp . getChilds ( ) [ : ] rev_childs . reverse ( ) node_stack . extend ( rev_childs ) return count