graph.h
2015-07-26 19:40
141 查看
#ifndef GRAPH_H #define GRAPH_H #include <iostream> #include <cmath> using namespace std; const int UNVISITED = 0; const int VISITED = 1; class Edge { public: int from; //edge start point int to; //edge end point int weight; //edge weight Edge() { from = to = -1; weight = 0; } Edge(int f, int t, int w) { from = f; to = t; weight = w; } void print() { cout<<"E"<<from<<"->"<<to<<" weight: "<<weight<<endl; } }; class Graph { public: int numVertex; // vertexs of graph int numEdge; // edges of graph int *Mark; // to sign vertex whether be visited int *Indegree; // indegree of vertex Graph(int numVert) { numVertex = numVert; numEdge = 0; Indegree = new int[numVertex]; Mark = new int[numVertex]; for (int i = 0; i < numVertex; i++) { Mark[i] = UNVISITED; Indegree[i] = 0; } } ~Graph() { delete []Mark; delete []Indegree; } bool isEdge(Edge oneEdge) { if (oneEdge.weight > 0 && oneEdge.weight < INFINITY && oneEdge.to >= 0) return true; else return false; } }; #endif
相关文章推荐
- POJ 3032 Card Trick 纸牌顺序
- LeetCode(144) Binary Tree Preorder Traversal
- python实现ftp的基本功能
- CodeForces 534D Program B
- 以正能量的点!!!
- Swift学习笔记(八)——赋值运算符的返回值问题
- 二维数组行列转换
- Veriog_Notes_Summary 2
- if语句
- 南阳OJ独木舟上的旅行
- 重装WINDOWS系统后,恢复ORACLE 10G 全过程记录
- centos7.1 QT5编译出现:cannot find -lGL 和 collect2:error:ld returned 1 exit status 错误
- VREFpin的作用,为什么要做参考
- Android百分比布局的解析与扩展
- 函数重载
- Android 图形锁的实现
- Swift
- HDU-1548 A strange lift(单源最短路 或 BFS)
- Centos7.1安装CUDA7.0
- HDU 1030 ( Delta-wave )