# Path: pyalgs/algorithms/commons/util.py
# def less(a, b):
# def greater(a, b):
# def cmp(a, b):
# def exchange(a, i, j):
# def is_sorted(a):
# 
# Path: pyalgs/data_structures/commons/bag.py
# class Bag(object):
#     def __init__(self):
#         self.stack = Stack.create()
# 
#     def add(self, item):
#         self.stack.push(item)
# 
#     def size(self):
#         return self.stack.size()
# 
#     def is_empty(self):
#         return self.stack.is_empty()
# 
#     def iterate(self):
#         return self.stack.iterate()
# 
#     @staticmethod
#     def create():
#         return Bag()


from pyalgs.algorithms.commons import util
from pyalgs.data_structures.commons.bag import Bag
        self.v = v
        self.w = w
        self.weight = weight

    def start(self):
        return self.v

    def end(self):
        return self.w

    def reverse(self):
        return Edge(self.w, self.v, self.weight)

    def either(self):
        return self.v

    def other(self, v):
        if self.v == v:
            return self.w
        elif self.w == v:
            return self.v
        else:
            raise ValueError('mismatched vertex detected')

    # use for python 2 comparison
    def __cmp__(self, other):
        return util.cmp(self.weight, other.weight)

    # user for python 3 comparison
    def __lt__(self, other):

# Path: pyalgs/algorithms/commons/util.py
# def less(a, b):
# def greater(a, b):
# def cmp(a, b):
# def exchange(a, i, j):
# def is_sorted(a):
# 
# Path: pyalgs/data_structures/commons/bag.py
# class Bag(object):
#     def __init__(self):
#         self.stack = Stack.create()
# 
#     def add(self, item):
#         self.stack.push(item)
# 
#     def size(self):
#         return self.stack.size()
# 
#     def is_empty(self):
#         return self.stack.is_empty()
# 
#     def iterate(self):
#         return self.stack.iterate()
# 
#     @staticmethod
#     def create():
#         return Bag()


# Path: pyalgs/data_structures/graphs/graph.py
from pyalgs.algorithms.commons import util
from pyalgs.data_structures.commons.bag import Bag

        self.v = v
        self.w = w
        self.weight = weight

    def start(self):
        return self.v

    def end(self):
        return self.w

    def reverse(self):
        return Edge(self.w, self.v, self.weight)

    def either(self):
        return self.v

    def other(self, v):
        if self.v == v:
            return self.w
        elif self.w == v:
            return self.v
        else:
            raise ValueError('mismatched vertex detected')

    # use for python 2 comparison
    def __cmp__(self, other):
        return util.cmp(self.weight, other.weight)

    # user for python 3 comparison
    def __lt__(self, other):

        return util.less(self.weight, other.weight)