~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to fdp/exprval.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* expr.c
 
2
 */
 
3
 
 
4
#include <stdio.h>
 
5
#include <stdlib.h>
 
6
#include <math.h>
 
7
#include "options.h"
 
8
#include "macros.h"
 
9
 
 
10
#ifdef DMALLOC
 
11
#include "dmalloc.h"
 
12
#endif
 
13
 
 
14
int DfltHeight  = 1000;
 
15
int DfltWidth   = 1000;
 
16
int DfltIters   = 40;
 
17
 
 
18
double     Width;    /* Width of bounding box */
 
19
double     Height;   /* Height of bounding box */
 
20
int        NumIters; /* Number of iterations in loop */
 
21
 
 
22
int        timer;    /* Iteration index */
 
23
double     Radius2;  /* Radius of interaction squared */
 
24
                     /* Anything outside of the radius has no effect on node */
 
25
double     CellW;    /* Width of interaction cell */
 
26
double     CellH;    /* Height of interaction cell */
 
27
 
 
28
double     UserK = 0.0;    /* User-supplied length */
 
29
double     Stretch = 1.2;  /* If maxVertLen used for K, multiply by Stretch
 
30
                              to avoid overlap */
 
31
double     K;        /* Edge length */
 
32
double     K2;       /* K*K */
 
33
double     T0;       /* Initial temperature */
 
34
#ifdef INCR
 
35
double     maxVertLen = 0.0;   /* maximum width or length of vertices */
 
36
#endif
 
37
 
 
38
void printValues ()
 
39
{
 
40
    fprintf (stderr, "NumIters %d ", NumIters);
 
41
    fprintf (stderr, "Width %g Height %g\n", Width, Height);
 
42
    fprintf (stderr, "CellW %g CellH %g\n", CellW, CellH);
 
43
    fprintf (stderr, "Radius2 %g Spring %g T0 %g\n", Radius2, K, T0);
 
44
}
 
45
 
 
46
double cool ()
 
47
{
 
48
  return (T0*(NumIters-timer))/NumIters;
 
49
}
 
50
 
 
51
 
 
52
void initValues (int v)
 
53
{
 
54
  if (Width == 0) Width = DfltWidth;
 
55
  if (Height == 0) Height = DfltHeight;
 
56
  if (NumIters == 0) NumIters = DfltIters;
 
57
 
 
58
  if (UserK > 0.0) K = UserK;
 
59
#ifdef INCR
 
60
  else K = Stretch * maxVertLen;
 
61
#else
 
62
  else K = sqrt((Width*Height)/v);
 
63
#endif
 
64
  K2 = K*K;
 
65
  T0 = Width/10;
 
66
  Radius2 = 9*K*K;
 
67
  CellW= 2*K;
 
68
  CellH= 2*K;
 
69
 
 
70
  if (Verbose)
 
71
    fprintf (stderr, "initValues: W %g H %g K %g T0 %g\n", Width, Height, K, T0);
 
72
}
 
73