# 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
            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)

    # user for python 3 comparison
    def __gt__(self, other):
        return util.greater(self.weight, other.weight)

    def __str__(self):
        return str(self.v) + ' =(' + str(self.weight) + ')=> ' + str(self.w)


class EdgeWeightedGraph(object):
    adjList = None
    V = 0

    def __init__(self, vertex_count):
        self.V = vertex_count
        self.adjList = [None] * vertex_count
        for v in range(vertex_count):
            self.adjList[v] = Bag()


# 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

            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)

    # user for python 3 comparison
    def __gt__(self, other):
        return util.greater(self.weight, other.weight)

    def __str__(self):
        return str(self.v) + ' =(' + str(self.weight) + ')=> ' + str(self.w)


class EdgeWeightedGraph(object):
    adjList = None
    V = 0

    def __init__(self, vertex_count):
        self.V = vertex_count
        self.adjList = [None] * vertex_count
        for v in range(vertex_count):
            self.adjList[v] = Bag()


    def add_edge(self, edge):