'Extracts all the keys and key defaults from the xml.'

def find_graphml_keys(self, graph_element):

    graphml_keys = {}
    graphml_key_defaults = {}
    for k in graph_element.findall(('{%s}key' % self.NS_GRAPHML)):
        attr_id = k.get('id')
        attr_type = k.get('attr.type')
        attr_name = k.get('attr.name')
        yfiles_type = k.get('yfiles.type')
        if (yfiles_type is not None):
            attr_name = yfiles_type
            attr_type = 'yfiles'
        if (attr_type is None):
            attr_type = 'string'
            warnings.warn(('No    key    type    for    id    %s.    Using    string' % attr_id))
        if (attr_name is None):
            raise nx.NetworkXError(('Unknown    key    for    id    %s.' % attr_id))
        graphml_keys[attr_id] = {'name': attr_name, 'type': self.python_type[attr_type], 'for': k.get('for')}
        default = k.find(('{%s}default' % self.NS_GRAPHML))
        if (default is not None):
            graphml_key_defaults[attr_id] = default.text
    return (graphml_keys, graphml_key_defaults)
