post_process.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #include <sfdpgen/spring_electrical.h>
  12. #include <stdbool.h>
  13. enum {SM_SCHEME_NORMAL, SM_SCHEME_NORMAL_ELABEL, SM_SCHEME_STRESS};
  14. struct StressMajorizationSmoother_struct {
  15. SparseMatrix D;/* distance matrix. The diagonal is removed hence the ia, ja structure is different from Lw and Lwd!! */
  16. SparseMatrix Lw;/* the weighted laplacian. with offdiag = -1/w_ij */
  17. SparseMatrix Lwd;/* the laplacian like matrix with offdiag = -scaling*d_ij/w_ij. RHS in stress majorization = Lwd.x */
  18. double* lambda;
  19. void (*data_deallocator)(void*);
  20. void *data;
  21. int scheme;
  22. double scaling;/* scaling. It is multiplied to Lwd. need to divide coordinate x at the end of the stress majorization process */
  23. double tol_cg;/* tolerance and maxit for conjugate gradient that solves the Laplacian system.
  24. typically the Laplacian only needs to be solved very crudely as it is part of an
  25. outer iteration.*/
  26. double maxit_cg;
  27. };
  28. typedef struct StressMajorizationSmoother_struct *StressMajorizationSmoother;
  29. void StressMajorizationSmoother_delete(StressMajorizationSmoother sm);
  30. enum {IDEAL_GRAPH_DIST, IDEAL_AVG_DIST, IDEAL_POWER_DIST};
  31. StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int dim, double lambda, double *x, int ideal_dist_scheme);
  32. double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, double *x, int maxit);
  33. /*-------------------- triangle/neirhborhood graph based smoother ------------------- */
  34. typedef StressMajorizationSmoother TriangleSmoother;
  35. #define TriangleSmoother_struct StressMajorizationSmoother_struct
  36. void TriangleSmoother_delete(TriangleSmoother sm);
  37. TriangleSmoother TriangleSmoother_new(SparseMatrix A, int dim, double *x,
  38. bool use_triangularization);
  39. void TriangleSmoother_smooth(TriangleSmoother sm, int dim, double *x);
  40. /*------------------ spring and spring-electrical based smoother */
  41. struct SpringSmoother_struct {
  42. SparseMatrix D;
  43. spring_electrical_control ctrl;
  44. };
  45. typedef struct SpringSmoother_struct *SpringSmoother;
  46. SpringSmoother SpringSmoother_new(SparseMatrix A, int dim, spring_electrical_control ctrl, double *x);
  47. void SpringSmoother_delete(SpringSmoother sm);
  48. void SpringSmoother_smooth(SpringSmoother sm, SparseMatrix A, int dim, double *x);
  49. /*------------------------------------------------------------------*/
  50. void post_process_smoothing(int dim, SparseMatrix A, spring_electrical_control ctrl, double *x);
  51. /*-------------------- sparse stress majorizationp ------------------- */
  52. typedef StressMajorizationSmoother SparseStressMajorizationSmoother;
  53. #define SparseStressMajorizationSmoother_struct StressMajorizationSmoother_struct
  54. void SparseStressMajorizationSmoother_delete(SparseStressMajorizationSmoother sm);
  55. SparseStressMajorizationSmoother
  56. SparseStressMajorizationSmoother_new(SparseMatrix A, int dim, double *x);
  57. double SparseStressMajorizationSmoother_smooth(SparseStressMajorizationSmoother sm, int dim, double *x, int maxit_sm);
  58. /*--------------------------------------------------------------*/