From 03d3803e15be201465fd5d01ae33285444531f62 Mon Sep 17 00:00:00 2001
From: erg <devnull@localhost>
Date: Fri, 25 Apr 2008 14:44:04 +0000
Subject: [PATCH] Split vtx_graph definition (sparsegraph.h) out of defs.h so
 that it can be used separately without the whole world being brought in;
 unify the versions of matrix_ops so that we only need one for both neato and
 topfish.

---
 lib/neatogen/defs.h       | 82 ++-------------------------------------
 lib/neatogen/matrix_ops.c | 12 +++---
 lib/neatogen/matrix_ops.h |  5 +--
 3 files changed, 12 insertions(+), 87 deletions(-)

diff --git a/lib/neatogen/defs.h b/lib/neatogen/defs.h
index 89e5057ff..f971ea186 100644
--- a/lib/neatogen/defs.h
+++ b/lib/neatogen/defs.h
@@ -23,73 +23,7 @@ extern "C" {
 
 #include "neato.h"
 
-#ifdef __cplusplus
-    enum Style { regular, invisible };
-    struct vtx_data {
-	int nedges;
-	int *edges;
-	float *ewgts;
-	Style *styles;
-	float *edists; /* directed dist reflecting the direction of the edge */
-    };
-
-    typedef int DistType;	/* must be signed!! */
-
-    inline double max(double x, double y) {
-	if (x >= y)
-	    return x;
-	else
-	    return y;
-    } inline double min(double x, double y) {
-	if (x <= y)
-	    return x;
-	else
-	    return y;
-    }
-
-    inline int max(int x, int y) {
-	if (x >= y)
-	    return x;
-	else
-	    return y;
-    }
-
-    inline int min(int x, int y) {
-	if (x <= y)
-	    return x;
-	else
-	    return y;
-    }
-
-    struct Point {
-	double x;
-	double y;
-	int operator==(Point other) {
-	    return x == other.x && y == other.y;
-    }};
-#else
-#undef inline
-#define inline
-#define NOTUSED(var)      (void) var
-
-#include <macros.h>
-
-#ifdef USE_STYLES
-    typedef enum { regular, invisible } Style;
-#endif
-    typedef struct {
-	int nedges;		/* no. of neighbors, including self */
-	int *edges;		/* edges[0..(nedges-1)] are neighbors; edges[0] is self */
-	float *ewgts;		/* preferred edge lengths */
-	float *eweights;	/* edge weights */
-	node_t *np;		/* original node */
-#ifdef USE_STYLES
-	Style *styles;
-#endif
-#ifdef DIGCOLA
-	float *edists; /* directed dist reflecting the direction of the edge */
-#endif
-    } vtx_data;
+#include "sparsegraph.h"
 
 #ifdef DIGCOLA
 #ifdef IPSEPCOLA
@@ -105,19 +39,9 @@ extern "C" {
 #endif
 #endif
 
-    typedef int DistType;	/* must be signed!! */
-
-#ifdef UNUSED
-    typedef struct {
-	double x;
-	double y;
-    } Point;
-#endif
-
-#endif
-
-#endif
 
 #ifdef __cplusplus
 }
 #endif
+
+#endif
diff --git a/lib/neatogen/matrix_ops.c b/lib/neatogen/matrix_ops.c
index 4f1db91e6..c4daf290e 100644
--- a/lib/neatogen/matrix_ops.c
+++ b/lib/neatogen/matrix_ops.c
@@ -16,15 +16,16 @@
 
 
 #include "matrix_ops.h"
+#include "memory.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
 
 static double p_iteration_threshold = 1e-3;
 
-boolean
+int
 power_iteration(double **square_mat, int n, int neigs, double **eigs,
-		double *evals, boolean initialize)
+		double *evals, int initialize)
 {
     /* compute the 'neigs' top eigenvectors of 'square_mat' using power iteration */
 
@@ -684,10 +685,11 @@ void set_vector_val(int n, double val, double *result)
 }
 
 /* inline */
-void set_vector_valf(int n, float val, float * result) {
+void set_vector_valf(int n, float val, float* result)
+{
     int i;
-    for (i=0; i<n; i++)
-        result[i]=val;
+    for (i = 0; i < n; i++)
+	result[i] = val;
 }
 
 /* inline */
diff --git a/lib/neatogen/matrix_ops.h b/lib/neatogen/matrix_ops.h
index 977cc306d..110c56d2e 100644
--- a/lib/neatogen/matrix_ops.h
+++ b/lib/neatogen/matrix_ops.h
@@ -23,7 +23,7 @@ extern "C" {
 #ifndef _MATRIX_OPS_H_
 #define _MATRIX_OPS_H_
 
-#include "defs.h"
+#include "sparsegraph.h"
 
     extern void cpvec(double *, int, int, double *);
     extern double dot(double *, int, int, double *);
@@ -65,8 +65,7 @@ extern "C" {
 				 double ***CC);
     extern void mult_sparse_dense_mat_transpose(vtx_data *, double **, int,
 						int, float ***);
-    extern boolean power_iteration(double **, int, int, double **, double *,
-				boolean);
+    extern int power_iteration(double **, int, int, double **, double *, int);
 
 
 /*****************************
-- 
2.40.0