def new_edge(self, node_a, node_b, cost=<NUM_LIT:1>):
<EOL>try:<EOL><INDENT>self.nodes[node_a]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise NonexistentNodeError(node_a)<EOL><DEDENT>try:<EOL><INDENT>self.nodes[node_b]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise NonexistentNodeError(node_b)<EOL><DEDENT>edge_id = self.generate_edge_id()<EOL>edge = {'<STR_LIT:id>': edge_id,<EOL>'<STR_LIT>': (node_a, node_b),<EOL>'<STR_LIT>': cost,<EOL>'<STR_LIT:data>': {}<EOL>}<EOL>self.edges[edge_id] = edge<EOL>self.nodes[node_a]['<STR_LIT>'].append(edge_id)<EOL>self._num_edges += <NUM_LIT:1><EOL>return edge_id<EOL>
Adds a new edge from node_a to node_b that has a cost.
        Returns the edge id of the new edge.