Changeset 1191:939ee6d1e525 in lemon for lemon
 Timestamp:
 11/16/10 08:19:11 (10 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/smart_graph.h
r1189 r1191 830 830 831 831 int first_red, first_blue; 832 int max_red, max_blue; 832 833 833 834 public: … … 891 892 892 893 SmartBpGraphBase() 893 : nodes(), arcs(), first_red(1), first_blue(1) {} 894 : nodes(), arcs(), first_red(1), first_blue(1), 895 max_red(1), max_blue(1) {} 894 896 895 897 typedef True NodeNumTag; … … 898 900 899 901 int nodeNum() const { return nodes.size(); } 900 int redNum() const { 901 return first_red == 1 ? 0 : nodes[first_red].partition_index + 1; 902 } 903 int blueNum() const { 904 return first_blue == 1 ? 0 : nodes[first_blue].partition_index + 1; 905 } 902 int redNum() const { return max_red + 1; } 903 int blueNum() const { return max_blue + 1; } 906 904 int edgeNum() const { return arcs.size() / 2; } 907 905 int arcNum() const { return arcs.size(); } 908 906 909 907 int maxNodeId() const { return nodes.size()1; } 910 int maxRedId() const { 911 return first_red == 1 ? 1 : nodes[first_red].partition_index; 912 } 913 int maxBlueId() const { 914 return first_blue == 1 ? 1 : nodes[first_blue].partition_index; 915 } 908 int maxRedId() const { return max_red; } 909 int maxBlueId() const { return max_blue; } 916 910 int maxEdgeId() const { return arcs.size() / 2  1; } 917 911 int maxArcId() const { return arcs.size()1; } … … 1042 1036 nodes[n].first_out = 1; 1043 1037 nodes[n].red = true; 1044 if (first_red == 1) { 1045 nodes[n].partition_index = 0; 1046 } else { 1047 nodes[n].partition_index = nodes[first_red].partition_index + 1; 1048 } 1038 nodes[n].partition_index = ++max_red; 1049 1039 nodes[n].partition_next = first_red; 1050 1040 first_red = n; … … 1058 1048 nodes[n].first_out = 1; 1059 1049 nodes[n].red = false; 1060 if (first_blue == 1) { 1061 nodes[n].partition_index = 0; 1062 } else { 1063 nodes[n].partition_index = nodes[first_blue].partition_index + 1; 1064 } 1050 nodes[n].partition_index = ++max_blue; 1065 1051 nodes[n].partition_next = first_blue; 1066 1052 first_blue = n; … … 1091 1077 first_red = 1; 1092 1078 first_blue = 1; 1079 max_blue = 1; 1080 max_red = 1; 1093 1081 } 1094 1082 … … 1245 1233 if (Parent::red(node)) { 1246 1234 first_red = nodes[n].partition_next; 1235 if (first_red != 1) { 1236 max_red = nodes[first_red].partition_index; 1237 } else { 1238 max_red = 1; 1239 } 1247 1240 Parent::notifier(RedNode()).erase(node); 1248 1241 } else { 1249 1242 first_blue = nodes[n].partition_next; 1243 if (first_blue != 1) { 1244 max_blue = nodes[first_blue].partition_index; 1245 } else { 1246 max_blue = 1; 1247 } 1250 1248 Parent::notifier(BlueNode()).erase(node); 1251 1249 }
Note: See TracChangeset
for help on using the changeset viewer.