1 #ifndef _VERTEX_H_ 2 #define _VERTEX_H_ 3 #include <ostream> 4 5 enum BFS_VERTEX_COLOR { 6 WHITE, 7 GRAY, 8 BLACK, 9 }; 10 11 struct Vertex { 12 int index; 13 BFS_VERTEX_COLOR color = WHITE; 14 int d = -1; 15 int pre_index = -1; 16 17 bool operator==(const Vertex& v) { 18 return index == v.index; 19 } 20 21 void set(BFS_VERTEX_COLOR color, int d, int pre_index) { 22 this->color = color; 23 this->d = d; 24 this->pre_index = pre_index; 25 } 26 }; 27 28 std::ostream & operator<<(std::ostream & os, const Vertex &v); 29 30 #endif
原文:https://www.cnblogs.com/ren-yu/p/14403975.html