-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphic.h
73 lines (54 loc) · 1.2 KB
/
graphic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: graphic.h
* Author: zephyr
*
* Created on July 11, 2016, 7:35 PM
*/
#ifndef GRAPHIC_H
#define GRAPHIC_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* GRAPHIC_H */
#define MAX_SIZE 30
#define INFINITE 8080
/*
* 邻接矩阵标示方法
*/
typedef struct map{
int vertex_num;
int matric[MAX_SIZE][MAX_SIZE];
}map;
typedef int dimession2[MAX_SIZE][MAX_SIZE];
void get_random_graph(map *g,int direct,int max_weight);
void tranverse_graph(map *g);
void tranverse_two_matric(dimession2 *matric,int size);
int init_graph(map *g,int size);
/*
* 邻接表 标示方法
**/
typedef struct edge
{
int from;
int to;
int weight;
struct edge *next;
}edge;
typedef struct vertex
{
int in;
edge *first_out;
}vertex;
typedef vertex AdjacentListMap[MAX_SIZE];
void addEdge(vertex *v,int from,int to,int weight);
void deleteEdge(vertex *v,int pos);
int adaptMatricMap2ListMap(map *g,AdjacentListMap *G);
void tranverseListMap(AdjacentListMap *G,int size);