directgraph.h

Màu nền
Font chữ
Font size
Chiều cao dòng

#include<stdio.h>

#include<stdlib.h>

#include"jval.h"

#include"jrb.h"

#include"dllist.h"

#define gray 1

#define white 0

#define black 2

#define MAX 10

#define limited 999.0

typedef struct _key

{

int visited;

int id;

int indegree;

int known;

double d;

struct _key *p;

}key;

typedef struct

{

JRB edges;

JRB vertices;

int maxvertices;

}Graph;

Graph creatgraph(Graph graph);

int compare(Jval a,Jval b);

Jval makekey(int id);

int addvertex(Graph *graph,char *name);

//tra ve id co ten name

int getID(Graph *graph,char *name);

//kiem tra co ton tai id khong

int existid(Graph *graph,int id);

void addEdge(Graph *graph,int v1,int v2,double trongso);

//return name of id

char * getvertex(Graph *graph,int id);

//Kiem tra co ton tai name khong

int existname(Graph *graph,char *name);

//kiem tra co canh noi giua v1 voi v2 khong

int hasedge(Graph *graph,int v1,int v2);

//tra ve bac ra cua dinh v

//cac dinh duoc luu trong output

int outdegree(Graph *graph,int v,int *output);

//tra ve bac vao cua dinh v

//cac dinh duoc luu trong output

int indegree(Graph *graph,int v,int *output);

void freegraph(Graph graph);

//Duyet do thi theo BFS

//ham func thuc hien chuc nang tai moi node cua do thi

void BFS (Graph *graph,int s,void (*func)(int,Graph *));

//Duyet do thi theo DFS

void DFS (Graph *graph,int s,void (*func)(int,Graph *));

//Dao nguoc do thi

Graph reversegraph(Graph *graph);

//sap xep Topo,in ra 1 thu tu Topo

void Tsort(Graph *graph,void (*func)(int,Graph *));

//Duong di ngan nhat khi khong co trong so

void shortestpath(Graph *graph,int u,int v);

//List all the way from goc to v

//khi truyen tham so trong chuong trinh chinh thi s = goc,v la id dinh den

void DFSrecusivelt(Graph *graph,int goc,int s,int v);

double trongso(Graph *graph,int u,int v);//return weight of (u->v)

//DIJKSTRA

void Dijkstra(Graph *graph,int s);

//Kiem tra co chu trinh ko,neu co in ra cac chu trinh

void cycledetecting(Graph *graph,int *dem);

//Tra ve so thanh phan lien thong

int checklienthong(Graph *graph);

Bạn đang đọc truyện trên: Truyen2U.Pro

#hongson