]> granicus.if.org Git - graphviz/commitdiff
Split vtx_graph definition (sparsegraph.h) out of defs.h so that it can be used
authorerg <devnull@localhost>
Fri, 25 Apr 2008 14:44:04 +0000 (14:44 +0000)
committererg <devnull@localhost>
Fri, 25 Apr 2008 14:44:04 +0000 (14:44 +0000)
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
lib/neatogen/matrix_ops.c
lib/neatogen/matrix_ops.h

index 89e5057ffa0cb381eefcda4e9a8d02f685d24ec0..f971ea1869c4b5eb556341f971fd5474d1759f37 100644 (file)
@@ -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
index 4f1db91e6c3323ac940a4fcb5d6c7065fe82d91f..c4daf290efc90e5370977a19cb6a5481a46936e1 100644 (file)
 
 
 #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 */
index 977cc306d6e4ef8e084d35afbb21043bca990e06..110c56d2ed3bf62724d6a5bb6e2db46ef6549987 100644 (file)
@@ -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);
 
 
 /*****************************