Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5583)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5598)
@@ -33,4 +33,6 @@
       this.assignmentGroupBox = new System.Windows.Forms.GroupBox();
       this.assignmentViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+      this.weightsRadioButton = new System.Windows.Forms.RadioButton();
+      this.distancesRadioButton = new System.Windows.Forms.RadioButton();
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
       this.splitContainer.Panel1.SuspendLayout();
@@ -108,4 +110,6 @@
       // visualizationTabPage
       // 
+      this.visualizationTabPage.Controls.Add(this.distancesRadioButton);
+      this.visualizationTabPage.Controls.Add(this.weightsRadioButton);
       this.visualizationTabPage.Controls.Add(this.pictureBox);
       this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
@@ -124,7 +128,7 @@
       this.pictureBox.BackColor = System.Drawing.Color.White;
       this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-      this.pictureBox.Location = new System.Drawing.Point(6, 6);
+      this.pictureBox.Location = new System.Drawing.Point(84, 6);
       this.pictureBox.Name = "pictureBox";
-      this.pictureBox.Size = new System.Drawing.Size(516, 269);
+      this.pictureBox.Size = new System.Drawing.Size(438, 269);
       this.pictureBox.TabIndex = 0;
       this.pictureBox.TabStop = false;
@@ -170,4 +174,28 @@
       this.assignmentViewHost.ViewsLabelVisible = true;
       this.assignmentViewHost.ViewType = null;
+      // 
+      // weightsRadioButton
+      // 
+      this.weightsRadioButton.AutoSize = true;
+      this.weightsRadioButton.Location = new System.Drawing.Point(6, 29);
+      this.weightsRadioButton.Name = "weightsRadioButton";
+      this.weightsRadioButton.Size = new System.Drawing.Size(64, 17);
+      this.weightsRadioButton.TabIndex = 1;
+      this.weightsRadioButton.Text = "Weights";
+      this.weightsRadioButton.UseVisualStyleBackColor = true;
+      this.weightsRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
+      // 
+      // distancesRadioButton
+      // 
+      this.distancesRadioButton.AutoSize = true;
+      this.distancesRadioButton.Checked = true;
+      this.distancesRadioButton.Location = new System.Drawing.Point(6, 6);
+      this.distancesRadioButton.Name = "distancesRadioButton";
+      this.distancesRadioButton.Size = new System.Drawing.Size(72, 17);
+      this.distancesRadioButton.TabIndex = 2;
+      this.distancesRadioButton.TabStop = true;
+      this.distancesRadioButton.Text = "Distances";
+      this.distancesRadioButton.UseVisualStyleBackColor = true;
+      this.distancesRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
       // 
       // QAPAssignmentView
@@ -185,4 +213,5 @@
       this.tabControl.ResumeLayout(false);
       this.visualizationTabPage.ResumeLayout(false);
+      this.visualizationTabPage.PerformLayout();
       ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
       this.valueTabPage.ResumeLayout(false);
@@ -203,4 +232,6 @@
     private System.Windows.Forms.GroupBox assignmentGroupBox;
     private MainForm.WindowsForms.ViewHost assignmentViewHost;
+    private System.Windows.Forms.RadioButton distancesRadioButton;
+    private System.Windows.Forms.RadioButton weightsRadioButton;
   }
 }
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5583)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5598)
@@ -37,4 +37,6 @@
   [Content(typeof(QAPAssignment), true)]
   public sealed partial class QAPAssignmentView : ItemView {
+    private Bitmap bitmap;
+
     public new QAPAssignment Content {
       get { return (QAPAssignment)base.Content; }
@@ -82,37 +84,39 @@
         if (Content == null) {
           pictureBox.Image = null;
+          if (bitmap != null) bitmap.Dispose();
+          bitmap = null;
         } else {
-          bool drawDistances = false;
+          Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+          bool drawDistances = distancesRadioButton.Checked;
           DoubleMatrix coordinates = Content.Coordinates;
           DoubleMatrix distances = Content.Distances;
+
           if ((coordinates == null || coordinates.Rows == 0)
-            && (distances == null || distances.Rows == 0)) return;
-          else if ((coordinates == null || coordinates.Rows == 0)
-            && Content.ViewCoordinates == null) {
-            coordinates = new DoubleMatrix(distances.Rows, 2);
-            int columns = (int)Math.Ceiling(Math.Sqrt(coordinates.Rows));
-            int x = 0, y = 0;
-            for (int i = 0; i < coordinates.Rows; i++) {
-              coordinates[i, 0] = 10 * x;
-              coordinates[i, 1] = 10 * y;
-              if (++x > columns) {
-                y++;
-                x = 0;
-              }
-            }
-            Content.ViewCoordinates = coordinates;
-            drawDistances = true;
-          } else if ((coordinates == null || coordinates.Rows == 0)
-            && Content.ViewCoordinates != null) {
-            coordinates = Content.ViewCoordinates;
-            drawDistances = true;
-          }
-
-          DoubleMatrix weights = Content.Weights;
-          Permutation permutation = Content.Assignment;
-          Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
-
-          if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
+            && (distances == null || distances.Rows == 0)) {
+            using (Graphics g = Graphics.FromImage(newBitmap)) {
+              string str = "No coordinates and no distance matrix specified.";
+              SizeF strSize = g.MeasureString(str, Font);
+              g.DrawString(str, Font, Brushes.Black, (float)(newBitmap.Width - strSize.Width) / 2.0f, (float)(newBitmap.Height - strSize.Height) / 2.0f);
+            }
+          } else {
+            if ((coordinates == null || coordinates.Rows == 0)
+              && Content.ViewCoordinates == null) {
+              coordinates = new DoubleMatrix(distances.Rows, 2);
+              double rad = (2 * Math.PI) / coordinates.Rows;
+              for (int i = 0; i < coordinates.Rows; i++) {
+                coordinates[i, 0] = 10 * Math.Cos(rad * i);
+                coordinates[i, 1] = 10 * Math.Sin(rad * i);
+              }
+              Content.ViewCoordinates = coordinates;
+            } else if ((coordinates == null || coordinates.Rows == 0)
+              && Content.ViewCoordinates != null) {
+              coordinates = Content.ViewCoordinates;
+            }
+
+            DoubleMatrix weights = Content.Weights;
+            Permutation assignment = Content.Assignment;
+
             double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
+            double maxWeight = double.MinValue, maxDistance = double.MinValue;
             for (int i = 0; i < coordinates.Rows; i++) {
               if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0];
@@ -120,4 +124,14 @@
               if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0];
               if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1];
+
+              for (int j = i + 1; j < coordinates.Rows; j++) {
+                if (weights[i, j] + weights[j, i] > maxWeight)
+                  maxWeight = weights[i, j] + weights[j, i];
+
+                if (distances[i, j] > maxDistance)
+                  maxDistance = distances[i, j];
+                else if (distances[j, i] > maxDistance)
+                  maxDistance = distances[j, i];
+              }
             }
 
@@ -129,24 +143,52 @@
             for (int i = 0; i < coordinates.Rows; i++)
               points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
-                                    bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
-
-            using (Graphics graphics = Graphics.FromImage(bitmap)) {
-              if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) {
-                for (int i = 0; i < permutation.Length; i++) {
-                  for (int j = 0; j < permutation.Length; j++) {
-                    if (i != j && weights[i, j] > 0) {
-                      graphics.DrawLine(Pens.Black, points[permutation[i]], points[permutation[j]]);
-                      float midX = ((points[permutation[i]].X + points[permutation[j]].X) / 2.0f) + 5;
-                      float midY = ((points[permutation[i]].Y + points[permutation[j]].Y) / 2.0f) - 5;
-                      graphics.DrawString(weights[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat), Font, Brushes.Black, midX, midY);
+                                    newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
+
+            Random rand = new Random();
+            using (Graphics graphics = Graphics.FromImage(newBitmap)) {
+              graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+              graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+              if ((assignment != null) && (assignment.Length == coordinates.Rows) && (assignment.Validate())) {
+                for (int i = 0; i < assignment.Length - 1; i++) {
+                  for (int j = i + 1; j < assignment.Length; j++) {
+                    Point start = points[assignment[i]], end = points[assignment[j]];
+                    string caption = String.Empty;
+                    double d = Math.Max(distances[i, j], distances[j, i]);
+                    if (drawDistances) {
+                      float width = (float)Math.Ceiling(5.0 * d / maxDistance);
+                      graphics.DrawLine(new Pen(Color.IndianRed, width), start, end);
+                      if (distances[i, j] != distances[j, i])
+                        caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat)
+                          + " / " + distances[j, i].ToString(CultureInfo.InvariantCulture.NumberFormat);
+                      else
+                        caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat);
+                    } else {
+                      double w = weights[i, j] + weights[j, i];
+                      if (w > 0) {
+                        float width = (float)Math.Ceiling(5.0 * w / maxWeight);
+                        graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
+                        caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
+                      }
+                      if (!String.IsNullOrEmpty(caption)) {
+                        double r = rand.NextDouble();
+                        while (r < 0.2 || r > 0.8) r = rand.NextDouble();
+                        float x = (float)(start.X + (end.X - start.X) * r + 5);
+                        float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
+                        graphics.DrawString(caption, Font, Brushes.Black, x, y);
+                      }
                     }
                   }
                 }
               }
-              for (int i = 0; i < points.Length; i++)
-                graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
+              for (int i = 0; i < points.Length; i++) {
+                Point p = new Point(points[assignment[i]].X - 3, points[assignment[i]].Y - 3);
+                graphics.FillRectangle(Brushes.Black, p.X, p.Y, 8, 8);
+                graphics.DrawString(i.ToString(), Font, Brushes.Black, p.X, p.Y + 10);
+              }
             }
           }
-          pictureBox.Image = bitmap;
+          pictureBox.Image = newBitmap;
+          if (bitmap != null) bitmap.Dispose();
+          bitmap = newBitmap;
         }
       }
@@ -163,5 +205,5 @@
             GenerateImage();
             break;
-          case "Permutation":
+          case "Assignment":
             GenerateImage();
             assignmentViewHost.Content = Content.Assignment;
@@ -178,4 +220,8 @@
       GenerateImage();
     }
+
+    private void radioButton_CheckedChanged(object sender, EventArgs e) {
+      GenerateImage();
+    }
   }
 }
