⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph_matrix.h

📁 这个代码包括求图的最大生成树和M着色问题.
💻 H
字号:

#ifndef GRAPH_MATRIX_H
#define GRAPH_MATRIX_H
/* 32 bit biggest int, to make two vertex disconnect, set their distance to MAX_INT */
#define MAX_INT 0xFFFFFFFF
#define MAX_DIS MAX_INT
#define OK 0
#define ERROR -1

/* structure: edge
 * description: to descript a edge
 */
class edge
{
public:
	int src;	//source vertex
	int dst;	//dest vertex
	size_t	length;//length from source to dest

	bool operator < (edge &e){ return length < e.length;}
	bool operator = (edge &e){ src = e.src; dst = e.dst; length = e.length; return true;}
};
/* class: mgraph
 * description: a weighted and directed graph, implementing as a matrix
 */
class mgraph
{
 public:
  size_t size;			/* how many vertex in the graph */
  size_t *edgematrix;		/* edge matrix edgematrix[i][j] is the length from i to j */

   mgraph(size_t size);	/* creater */
   ~mgraph();		/* destroyer */

   int connect(int i, int j, int distance); /* make i and j connected, the distance between i and j is distance */
   int read_file(char *file);	/* read graph from file */
   int print();					/* print the graph out */
   int max_span_tree(mgraph &g);		/* return he's max spanning tree */
 private:

};
#endif	/*  GRAPH_MATRIX_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -