@SuppressWarnings("unchecked")
	private LinkedList<WeightedEdge> bucketSortEdges
		(WeightedGraph<? extends WeightedEdge> g) {
		
		// initialize buckets
		LinkedList<WeightedEdge>[] buckets =
			new LinkedList[Thorup.msb(WeightedEdge.MAXIMUM_EDGE_WEIGHT)];
		
		for (int i = 0; i < buckets.length; i++) {
			buckets[i] = new LinkedList<WeightedEdge>();
		}
		
		// bucket edges
		for (int v = 0; v < g.getNumberOfVertices(); v++) {
		
			for (WeightedEdge e : g.getIncidentEdges(v)) {
				if (e.getSource() < e.getTarget()) {
					buckets[Thorup.msb(e.getWeight())].add(e);
				}
			}
		}
		
		// create sorted edge array
		LinkedList<WeightedEdge> q = new LinkedList<WeightedEdge>();
		
		for (int i = 0; i < buckets.length; i++) {
			for (WeightedEdge e : buckets[i]) {
				q.addLast(e);
			}
		}
		
		return q;
	}