def add_edge(self, begin_node=None, end_node=None, edge_function=None):
    "Adds an edge mapping one node to another, required input is begin_node (it's name)\n        end_node, and the edge function"
    edge_match = re.compile('edge_{0}_{1}'.format(begin_node, end_node))
    keys = list(self.__dict__.keys())
    iterator = 0
    for key in keys:
        if re.match(edge_match, key):
            iterator += 1
    edge_name = 'edge_{0}_{1}_{2:0>3d}'.format(begin_node, end_node, iterator)
    self.__dict__[edge_name] = edge_function
    self.edges.append(edge_name)
    edge_matrix = np.zeros((len(self.state), len(self.state)))
    begin_position = self.node_names.index(begin_node)
    end_position = self.node_names.index(end_node)
    edge_matrix[end_position][begin_position] = 1
    edge_matrix = np.matrix(edge_matrix)
    self.edge_matrices.append(edge_matrix)
    self.display_graph.add_edge(begin_node, end_node)
    self.display_layout = networkx.spring_layout(self.display_graph)
Adds an edge mapping one node to another, required input is begin_node (it's name)
end_node, and the edge function
def add_edge(self, begin_node=None, end_node=None, edge_function=None):
    "Adds an edge mapping one node to another, required input is begin_node (it's name)\n        end_node, and the edge function"
    edge_match = re.compile('edge_{0}_{1}'.format(begin_node, end_node))
    keys = list(self.__dict__.keys())
    iterator = 0
    for key in keys:
        if re.match(edge_match, key):
            iterator += 1
    edge_name = 'edge_{0}_{1}_{2:0>3d}'.format(begin_node, end_node, iterator)
    self.__dict__[edge_name] = edge_function
    self.edges.append(edge_name)
    edge_matrix = np.zeros((len(self.state), len(self.state)))
    begin_position = self.node_names.index(begin_node)
    end_position = self.node_names.index(end_node)
    edge_matrix[end_position][begin_position] = 1
    edge_matrix = np.matrix(edge_matrix)
    self.edge_matrices.append(edge_matrix)
    self.display_graph.add_edge(begin_node, end_node)
    self.display_layout = networkx.spring_layout(self.display_graph)