def parse(self, data):
graph = self._init_graph()<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise ParserError('<STR_LIT>')<EOL><DEDENT>elif '<STR_LIT>' not in data:<EOL><INDENT>raise ParserError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in data:<EOL><INDENT>version_info = data['<STR_LIT>']['<STR_LIT>'].replace('<STR_LIT:U+0020>', '<STR_LIT>').split('<STR_LIT:->')<EOL>self.version = version_info[<NUM_LIT:1>]<EOL>if '<STR_LIT>' in version_info[-<NUM_LIT:1>]:<EOL><INDENT>version_info[-<NUM_LIT:1>] = version_info[-<NUM_LIT:1>].split('<STR_LIT>')[-<NUM_LIT:1>]<EOL><DEDENT>self.revision = version_info[-<NUM_LIT:1>]<EOL><DEDENT>alias_dict = {}<EOL>for node in data['<STR_LIT>']:<EOL><INDENT>local_addresses = [alias['<STR_LIT>'] for alias in node['<STR_LIT>']]<EOL>alias_dict[node['<STR_LIT>']] = local_addresses<EOL><DEDENT>for link in data['<STR_LIT>']:<EOL><INDENT>try:<EOL><INDENT>source = link['<STR_LIT>']<EOL>target = link['<STR_LIT>']<EOL>cost = link['<STR_LIT>']<EOL>properties = {<EOL>'<STR_LIT>': link['<STR_LIT>'],<EOL>'<STR_LIT>': link['<STR_LIT>']<EOL>}<EOL><DEDENT>except KeyError as e:<EOL><INDENT>raise ParserError('<STR_LIT>' % e)<EOL><DEDENT>for node in [source, target]:<EOL><INDENT>if node not in alias_dict:<EOL><INDENT>continue<EOL><DEDENT>graph.add_node(node, local_addresses=alias_dict[node])<EOL><DEDENT>if cost == float('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>cost = float(cost) / <NUM_LIT><EOL>graph.add_edge(source, target, weight=cost, **properties)<EOL><DEDENT>return graph<EOL>
Converts a dict representing an OLSR 0.6.x topology
to a NetworkX Graph object, which is then returned.
Additionally checks for "config" data in order to determine version and revision.