<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self, properties=True):
 """ Encode the Eds as a dictionary suitable for JSON serialization. """

        nodes = {}
        for node in self.nodes():
            nd = {
                'label': node.pred.short_form(),
                'edges': self.edges(node.nodeid)
            }
            if node.lnk is not None:
                nd['lnk'] = {'from': node.cfrom, 'to': node.cto}
            if properties:
                if node.cvarsort is not None:
                    nd['type'] = node.cvarsort
                props = node.properties
                if props:
                    nd['properties'] = props
            if node.carg is not None:
                nd['carg'] = node.carg
            nodes[node.nodeid] = nd
        return {'top': self.top, 'nodes': nodes}