private void wmedian(int iteration) {
		int maxRank = graph.getMaxRank();
		if (maxRank == GraphLayoutParameters.MIN_RANK) {
			return;
		}

		if (iteration % 2 == 0) {
			for (int rank = 1; rank <= maxRank; rank++) {
				for (LayoutNode v : graph.getRankOrder(rank)) {
					vertexMedianValues.put(v, medianValue(v, rank - 1));
				}

				/*
				 * Sort vertices with the current rank based on median values.
				 */
				List<LayoutNode> vertices = new ArrayList<>(graph.getRankOrder(rank));
				List<Double> medianValues = new ArrayList<>(new HashSet<>(vertexMedianValues.values()));
				Collections.sort(medianValues);
				final Map<LayoutNode, Integer> vertexPositions = new HashMap<>();
				int position = 0;
				for (Double m : medianValues) {
					for (int i = 0; i < vertices.size(); i++) {
						if (vertexMedianValues.get(vertices.get(i)).equals(m)) {
							if (m.equals(-1.0)) {
								vertexPositions.put(vertices.get(i), i);
							} else {
								while (vertexPositions.values().contains(position)) {
									position++;
								}
								vertexPositions.put(vertices.get(i), position);
							}
						}
					}
				}

				Collections.sort(vertices, new Comparator<LayoutNode>() {

					@Override
					public int compare(LayoutNode o1, LayoutNode o2) {
						return Integer.compare(vertexPositions.get(o1), vertexPositions.get(o2));
					}

				});

				graph.setRankOrder(rank, vertices);
			}
		}
	}