The LevAWC Project
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
algo.h
Go to the documentation of this file.
1 /*
2  * _____
3  * ANSI / ___/
4  * / /__
5  * \___/
6  *
7  * Filename: algo.h
8  * Author : Dan Levin
9  * Date : Mon Feb 16 10:06:22 2015
10  * Version : 0.51
11  * ---
12  * Description: Miscellanoeus algorithms
13  *
14  * Date Revision message
15  * 150331 This code ready for version 0.51
16  *
17  */
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <malloc.h>
26 #include <assert.h>
27 #include <float.h>
28 #include <math.h>
29 
30 #include "slist.h"
31 #include "queue.h"
32 #include "graph.h"
33 
34 #ifndef _ALGO_H_
35 #define _ALGO_H_
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45  typedef struct DspVertexdata_
46  {
51  void *data;
52 
53  double weight;
54  VertexColor color;
55  double distance;
56 
57  /* Pointer to parent vertex */
58  struct DspVertexdata_ *parent;
59  } *DspVertexdata;
60 
65  typedef struct MstVertexdata_
66  {
71  void *data;
72 
73  double weight;
74  VertexColor color;
75  double key;
76 
77  /* Pointer to parent vertex */
78  struct MstVertexdata_ *parent;
79  } *MstVertexdata;
80 
85  typedef struct TspVertexdata_
86  {
91  void *data;
92 
93  double x, y;
94  VertexColor color;
95  } *TspVertexdata;
96 
101  typedef struct BfsVertexdata_
102  {
107  void *data;
108 
109  int hops;
110  VertexColor color;
111  } *BfsVertexdata;
112 
117  typedef struct DfsVertexdata_
118  {
123  void *data;
124 
125  VertexColor color;
126  } *DfsVertexdata;
127 
128 
129  /* --- Function interface/declarations --- */
130 
135  int ALGOdsp(Graph gr, const DspVertexdata start, Slist *spath,
136  int (*match)(const void *key1, const void *key2));
137 
142  int ALGOmst(Graph gr, const MstVertexdata start, Slist *span,
143  int (*match)(const void *key1, const void *key2));
144 
149  int ALGOtsp(Slist vertices, const TspVertexdata start, Slist *tour,
150  int (*match)(const void *key1, const void *key2));
151 
156  int ALGObfs(Graph gr, const BfsVertexdata start, Slist *hops,
157  int (*match)(const void *key1, const void *key2));
158 
163  int ALGOdfs(Graph gr, Slist *ordered);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* _ALGO_H_ */