| 1 | /* $Id$ $Revision$ */ |
| 2 | /* vim:set shiftwidth=4 ts=8: */ |
| 3 | |
| 4 | /************************************************************************* |
| 5 | * Copyright (c) 2011 AT&T Intellectual Property |
| 6 | * All rights reserved. This program and the accompanying materials |
| 7 | * are made available under the terms of the Eclipse Public License v1.0 |
| 8 | * which accompanies this distribution, and is available at |
| 9 | * http://www.eclipse.org/legal/epl-v10.html |
| 10 | * |
| 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ |
| 12 | *************************************************************************/ |
| 13 | |
| 14 | #ifndef POST_PROCESS_H |
| 15 | #define POST_PROCESS_H |
| 16 | |
| 17 | #include "spring_electrical.h" |
| 18 | |
| 19 | enum {SM_SCHEME_NORMAL, SM_SCHEME_NORMAL_ELABEL, SM_SCHEME_UNIFORM_STRESS, SM_SCHEME_MAXENT, SM_SCHEME_STRESS_APPROX, SM_SCHEME_STRESS}; |
| 20 | |
| 21 | struct StressMajorizationSmoother_struct { |
| 22 | SparseMatrix D;/* distance matrix. The diagonal is removed hence the ia, ja structure is different from Lw and Lwd!! */ |
| 23 | SparseMatrix Lw;/* the weighted laplacian. with offdiag = -1/w_ij */ |
| 24 | SparseMatrix Lwd;/* the laplacian like matrix with offdiag = -scaling*d_ij/w_ij. RHS in stress majorization = Lwd.x */ |
| 25 | real* lambda; |
| 26 | void (*data_deallocator)(void*); |
| 27 | void *data; |
| 28 | int scheme; |
| 29 | real scaling;/* scaling. It is multiplied to Lwd. need to divide coordinate x at the end of the stress majorization process */ |
| 30 | real tol_cg;/* tolerance and maxit for conjugate gradient that solves the Laplacian system. |
| 31 | typically the Laplacian only needs to be solved very crudely as it is part of an |
| 32 | outer iteration.*/ |
| 33 | int maxit_cg; |
| 34 | }; |
| 35 | |
| 36 | typedef struct StressMajorizationSmoother_struct *StressMajorizationSmoother; |
| 37 | |
| 38 | void StressMajorizationSmoother_delete(StressMajorizationSmoother sm); |
| 39 | |
| 40 | enum {IDEAL_GRAPH_DIST, IDEAL_AVG_DIST, IDEAL_POWER_DIST}; |
| 41 | StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int dim, real lambda, real *x, int ideal_dist_scheme); |
| 42 | |
| 43 | real StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, real *x, int maxit, real tol); |
| 44 | /*-------------------- triangle/neirhborhood graph based smoother ------------------- */ |
| 45 | typedef StressMajorizationSmoother TriangleSmoother; |
| 46 | |
| 47 | #define TriangleSmoother_struct StressMajorizationSmoother_struct |
| 48 | |
| 49 | void TriangleSmoother_delete(TriangleSmoother sm); |
| 50 | |
| 51 | TriangleSmoother TriangleSmoother_new(SparseMatrix A, int dim, real lambda, real *x, int use_triangularization); |
| 52 | |
| 53 | void TriangleSmoother_smooth(TriangleSmoother sm, int dim, real *x); |
| 54 | |
| 55 | |
| 56 | |
| 57 | /*------------------ spring and spring-electrical based smoother */ |
| 58 | |
| 59 | struct SpringSmoother_struct { |
| 60 | SparseMatrix D; |
| 61 | spring_electrical_control ctrl; |
| 62 | }; |
| 63 | |
| 64 | typedef struct SpringSmoother_struct *SpringSmoother; |
| 65 | |
| 66 | SpringSmoother SpringSmoother_new(SparseMatrix A, int dim, spring_electrical_control ctrl, real *x); |
| 67 | |
| 68 | void SpringSmoother_delete(SpringSmoother sm); |
| 69 | |
| 70 | void SpringSmoother_smooth(SpringSmoother sm, SparseMatrix A, real *node_weights, int dim, real *x); |
| 71 | /*------------------------------------------------------------------*/ |
| 72 | |
| 73 | void post_process_smoothing(int dim, SparseMatrix A, spring_electrical_control ctrl, real *node_weights, real *x, int *flag); |
| 74 | |
| 75 | /*-------------------- sparse stress majorizationp ------------------- */ |
| 76 | typedef StressMajorizationSmoother SparseStressMajorizationSmoother; |
| 77 | |
| 78 | #define SparseStressMajorizationSmoother_struct StressMajorizationSmoother_struct |
| 79 | |
| 80 | void SparseStressMajorizationSmoother_delete(SparseStressMajorizationSmoother sm); |
| 81 | |
| 82 | enum {WEIGHTING_SCHEME_NONE, WEIGHTING_SCHEME_INV_DIST, WEIGHTING_SCHEME_SQR_DIST}; |
| 83 | SparseStressMajorizationSmoother SparseStressMajorizationSmoother_new(SparseMatrix A, int dim, real lambda, real *x, |
| 84 | int weighting_scheme, int scale_initial_coord); |
| 85 | |
| 86 | real SparseStressMajorizationSmoother_smooth(SparseStressMajorizationSmoother sm, int dim, real *x, int maxit_sm, real tol); |
| 87 | |
| 88 | real get_stress(int m, int dim, int *iw, int *jw, real *w, real *d, real *x, real scaling, void *data, int weighted); |
| 89 | |
| 90 | real get_full_stress(SparseMatrix A, int dim, real *x, int weighting_scheme); |
| 91 | void dump_distance_edge_length(char *outfile, SparseMatrix A, int dim, real *x); |
| 92 | |
| 93 | /*--------------------------------------------------------------*/ |
| 94 | |
| 95 | #endif |
| 96 | |
| 97 | |