def simplex_optimal(self, t):
        '''
        API:
            simplex_optimal(self, t)
        Description:
            Checks if the current solution is optimal, if yes returns True,
            False otherwise.
        Pre:
            'flow' attributes represents a solution.
        Input:
            t: Graph instance tat reperesents spanning tree solution.
        Return:
            Returns True if the current solution is optimal (optimality
            conditions are satisfied), else returns False
        '''
        for e in self.edge_attr:
            if e in t.edge_attr:
                continue
            flow_ij = self.edge_attr[e]['flow']
            potential_i = self.get_node(e[0]).get_attr('potential')
            potential_j = self.get_node(e[1]).get_attr('potential')
            capacity_ij = self.edge_attr[e]['capacity']
            c_ij = self.edge_attr[e]['cost']
            cpi_ij = c_ij - potential_i + potential_j
            if flow_ij==0:
                if cpi_ij < 0:
                    return False
            elif flow_ij==capacity_ij:
                if cpi_ij > 0:
                    return False
        return True
def simplex_optimal ( self , t ) : for e in self . edge_attr : if e in t . edge_attr : continue flow_ij = self . edge_attr [ e ] [ 'flow' ] potential_i = self . get_node ( e [ 0 ] ) . get_attr ( 'potential' ) potential_j = self . get_node ( e [ 1 ] ) . get_attr ( 'potential' ) capacity_ij = self . edge_attr [ e ] [ 'capacity' ] c_ij = self . edge_attr [ e ] [ 'cost' ] cpi_ij = c_ij - potential_i + potential_j if flow_ij == 0 : if cpi_ij < 0 : return False elif flow_ij == capacity_ij : if cpi_ij > 0 : return False return True
API:
            simplex_optimal(self, t)
        Description:
            Checks if the current solution is optimal, if yes returns True,
            False otherwise.
        Pre:
            'flow' attributes represents a solution.
        Input:
            t: Graph instance tat reperesents spanning tree solution.
        Return:
            Returns True if the current solution is optimal (optimality
            conditions are satisfied), else returns False