From 55360c17e41312f8cb0685882dea1db9dd968a84 Mon Sep 17 00:00:00 2001
From: erg <devnull@localhost>
Date: Wed, 29 Apr 2009 00:48:48 +0000
Subject: [PATCH] Add support for mds model, in which user-supplied edge
 distances are used rather than weighted shortest paths.

---
 lib/neatogen/constrained_majorization.c       | 14 ++++++++++++++
 lib/neatogen/constrained_majorization_ipsep.c | 15 ++++++++++++++-
 lib/neatogen/neato.h                          |  1 +
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/lib/neatogen/constrained_majorization.c b/lib/neatogen/constrained_majorization.c
index f11c4c3f7..57e5318af 100644
--- a/lib/neatogen/constrained_majorization.c
+++ b/lib/neatogen/constrained_majorization.c
@@ -159,6 +159,9 @@ stress_majorization_with_hierarchy(
 	if (maxi==0)
 		return iterations;
 
+    if (Verbose)
+	start_timer();
+
     if (model == MODEL_SUBSET) {
         /* weight graph to separate high-degree nodes */
         /* and perform slower Dijkstra-based computation */
@@ -173,12 +176,21 @@ stress_majorization_with_hierarchy(
             agerr(AGPREV,
                   "is undefined. Reverting to the shortest path model.\n");
         }
+    } else if (model == MODEL_MDS) {
+	if (Verbose)
+	    fprintf(stderr, "Calculating MDS model");
+	Dij = mdsModel(graph, n);
     }
     if (!Dij) {
         if (Verbose)
             fprintf(stderr, "Calculating shortest paths");
         Dij = compute_apsp_packed(graph, n);
     }
+    if (Verbose) {
+	fprintf(stderr, ": %.2f sec\n", elapsed_sec());
+	fprintf(stderr, "Setting initial positions");
+	start_timer();
+    }
 
 	diameter=-1;
 	length = n+n*(n-1)/2;
@@ -253,6 +265,8 @@ stress_majorization_with_hierarchy(
      */
 	constant_term=(float)(n*(n-1)/2);
 	
+    if (Verbose) fprintf(stderr, ": %.2f sec", elapsed_sec());
+
 	/**************************
 	** Laplacian computation **
 	**************************/
diff --git a/lib/neatogen/constrained_majorization_ipsep.c b/lib/neatogen/constrained_majorization_ipsep.c
index b0072077f..ff15067d9 100644
--- a/lib/neatogen/constrained_majorization_ipsep.c
+++ b/lib/neatogen/constrained_majorization_ipsep.c
@@ -121,6 +121,9 @@ int stress_majorization_cola(
     if (maxi == 0)
 	return iterations;
 
+    if (Verbose)
+	start_timer();
+
     if (model == MODEL_SUBSET) {
 	/* weight graph to separate high-degree nodes */
 	/* and perform slower Dijkstra-based computation */
@@ -135,12 +138,21 @@ int stress_majorization_cola(
 	    agerr(AGPREV,
 		  "is undefined. Reverting to the shortest path model.\n");
 	}
+    } else if (model == MODEL_MDS) {
+	if (Verbose)
+	    fprintf(stderr, "Calculating MDS model");
+	Dij = mdsModel(graph, n);
     }
     if (!Dij) {
 	if (Verbose)
-	    fprintf(stderr, "Calculating shortest paths\n ");
+	    fprintf(stderr, "Calculating shortest paths");
 	Dij = compute_apsp_packed(graph, n);
     }
+    if (Verbose) {
+	fprintf(stderr, ": %.2f sec\n", elapsed_sec());
+	fprintf(stderr, "Setting initial positions");
+	start_timer();
+    }
 
     diameter = -1;
     length = n + n * (n - 1) / 2;
@@ -178,6 +190,7 @@ int stress_majorization_cola(
     for (i = 0; i < n; i++) {
 	d_coords[1][i] -= y_0;
     }
+    if (Verbose) fprintf(stderr, ": %.2f sec", elapsed_sec());
 
 	/**************************
 	** Laplacian computation **
diff --git a/lib/neatogen/neato.h b/lib/neatogen/neato.h
index 62e4a6a68..c5404f306 100644
--- a/lib/neatogen/neato.h
+++ b/lib/neatogen/neato.h
@@ -25,6 +25,7 @@
 #define MODEL_SHORTPATH      0
 #define MODEL_CIRCUIT        1
 #define MODEL_SUBSET         2
+#define MODEL_MDS            3
 
 #define MODE_KK          0
 #define MODE_MAJOR       1
-- 
2.40.0