NeoPZ
label.cpp
Go to the documentation of this file.
1 #include "sloan.h"
2  /* @brief Purpose: Label a graph for small profile and rms wavefront */
3 int label_ (int64_t *n, int64_t *e2, int64_t *adj, int64_t *
4  xadj, int64_t *nnn, int64_t *iw, int64_t *oldpro, int64_t *newpro)
5 {
6  /* System generated locals */
7  int64_t i__1;
8  /* Local variables */
9  static int64_t i, snode, i1, i2, i3;
10  static int64_t nc;
11  static int64_t lstnum;
12 
13 /* INPUT: */
14 /* ------ */
15 /* N - Total number of nodes in graph */
16 /* E2 - Twice the number of edges in the graph = XADJ(N+1)-1 */
17 /* ADJ - Adjacency list for all nodes in graph */
18 /* - List of length 2E where E is the number of edges in */
19 /* the graph and 2E = XADJ(N+1)-1 */
20 /* XADJ - Index vector for ADJ */
21 /* - Nodes adjacentto node I are found in ADJ(J), where */
22 /* J = XADJ(I),XADJ(I)+1, ..., XADJ(I+1)-1 */
23 /* - Degreeof node I given by XADJ(I+1)-XADJ(I) */
24 /* NNN - Undefined */
25 /* IW - Undefined */
26 /* OLDPRO - Undefined */
27 /* NEWPRO - Undefined */
28 
29 /* OUTPUT: */
30 /* ------- */
31 /* N - Unchanged */
32 /* E2 - Unchanged */
33 /* ADJ - Unchanged */
34 /* XADJ - Unchanged */
35 /* NNN - List of new node numbers */
36 /* - New number for node I given by NNN(I) */
37 /* - If original node numbers give a smaller profile then */
38 /* NNN is set so that NNN(I)=I for I=1,N */
39 /* IW - Not used */
40 /* OLDPRO - Profile using original node numbering */
41 /* NEWPRO - Profile for new node numbering */
42 /* - If original profile is smaller than new profile, then */
43 /* - original node numbers are used and NEWPRO=OLDPRO */
44 
45 /* SUBROUTINES CALLED: DIAMTR, NUMBER, PROFIL */
46 /* ------------------- */
47 
48 /* PROGRAMMER: Scott Sloan */
49 /* ----------- */
50 
51 /* LAST MODIFIED: 10 March 1989 Scott Sloan */
52 /* -------------- */
53 /* ***********************************************************************
54  */
55 
56 
57 /* Set all new node numbers =0 */
58 /* This is used to denote all visible nodes */
59 
60  /* Parameter adjustments */
61  --iw;
62  --nnn;
63  --xadj;
64  --adj;
65 
66  /* Function Body */
67  i__1 = *n;
68  for (i = 1; i <= i__1; ++i)
69  {
70  nnn[i] = 0L;
71 /* L10: */
72  }
73 
74 /* Define offsets */
75 
76  i1 = 1;
77  i2 = i1 + *n;
78  i3 = i2 + *n + 1;
79 
80 /* Loop while some nodes remain unnumbered */
81 
82  lstnum = 0;
83 L20:
84  if (lstnum < *n)
85  {
86 
87 /* Find end points of p-diameter for nodes in this component */
88 /* Compute distances of nodes from end node */
89 
90  diamtr_ (n, e2, &adj[1], &xadj[1], &nnn[1], &iw[i1], &iw[i2], &iw[i3],
91  &snode, &nc);
92 
93 /* Number nodes in this component */
94 
95  number_ (n, &nc, &snode, &lstnum, e2, &adj[1], &xadj[1], &nnn[1], &iw[
96  i1], &iw[i2]);
97  goto L20;
98  }
99 /* Compute profiles for old and new node numbers */
100 
101  profi1_ (n, &nnn[1], e2, &adj[1], &xadj[1], oldpro, newpro);
102 
103 /* Use original numbering if it gives a smaller profile */
104 
105  ++adj;
106  ++xadj;
107 
108  return 0;
109 } /* label_ */
int diamtr_(int64_t *n, int64_t *e2, int64_t *adj, int64_t *xadj, int64_t *mask, int64_t *ls, int64_t *xls, int64_t *hlevel, int64_t *snode, int64_t *nc)
Purpose: Find nodes which define a pseudo-diameter of a graph and store distances from end node...
Definition: diamtr.cpp:4
int label_(int64_t *n, int64_t *e2, int64_t *adj, int64_t *xadj, int64_t *nnn, int64_t *iw, int64_t *oldpro, int64_t *newpro)
Definition: label.cpp:3
int number_(int64_t *, int64_t *nc, int64_t *snode, int64_t *lstnum, int64_t *, int64_t *adj, int64_t *xadj, int64_t *s, int64_t *q, int64_t *p)
Definition: number.cpp:4
int profi1_(int64_t *n, int64_t *nnn, int64_t *, int64_t *adj, int64_t *xadj, int64_t *oldpro, int64_t *newpro)
Definition: profi1.cpp:5