/[zanavi_public1]/navit/navit/fib-1.1/fibtest2.c
ZANavi

Contents of /navit/navit/fib-1.1/fibtest2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 3411 byte(s)
import files
1 /*-
2 * Copyright 1997, 1998-2003 John-Mark Gurney.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "fib.h"
31
32 int
33 main(void) {
34 struct fibheap *a;
35 void *arr[10];
36 int i;
37 a = fh_makekeyheap();
38
39 for (i=1 ; i < 10 ; i++)
40 {
41 arr[i]= fh_insertkey(a,0,(void *)i);
42 printf("adding: 0 %d \n",i);
43 }
44
45 printf(" \n");
46 fh_replacekey(a, arr[1],-38);
47 fh_replacekey(a, arr[7],-34);
48
49 printf("wert(minkey) %d\n",fh_minkey(a));
50 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
51 fh_replacekey(a, arr[2],-55);
52 fh_replacekey(a, arr[5],-56);
53 printf("Wert(minkey) %d\n",fh_minkey(a));
54 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
55
56 fh_replacekey(a, arr[4],-1);
57 fh_replacekey(a, arr[2],-102);
58 fh_replacekey(a, arr[6],-1);
59 fh_replacekey(a, arr[9],-1);
60 fh_replacekey(a, arr[8],-4);
61 printf("Wert(minkey) %d\n",fh_minkey(a));
62 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
63 fh_replacekey(a, arr[3],-74);
64 fh_replacekey(a, arr[8],-55);
65 fh_replacekey(a, arr[4],-2);
66
67 printf("Wert(minkey) %d\n",fh_minkey(a));
68 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
69 fh_replacekey(a, arr[4],-3);
70 fh_replacekey(a, arr[6],-2);
71 fh_replacekey(a, arr[7],-99);
72 printf("Wert(minkey) %d\n",fh_minkey(a));
73 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
74 fh_replacekey(a, arr[6],-3);
75 fh_replacekey(a, arr[4],-4);
76 fh_replacekey(a, arr[8],-94);
77 fh_replacekey(a, arr[9],-2);
78 printf("Wert(minkey) %d\n",fh_minkey(a));
79 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
80 fh_replacekey(a, arr[6],-4);
81
82 printf("Wert(minkey) %d\n",fh_minkey(a));
83 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
84
85 printf("Wert(minkey) %d\n",fh_minkey(a));
86 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
87 /*fh_replacekey(a, arr[9],-3);*/
88 printf("Wert(minkey) %d\n",fh_minkey(a));
89 printf("Knoten: %d\n\n", (int)fh_extractmin(a));
90
91 /*fh_replacekey(a, arr[9],-49);*/
92
93 fh_deleteheap(a);
94
95 return 0;
96 }

   
Visit the ZANavi Wiki