62 vertex_descriptor a = boost::add_vertex(g);
63 vertex_descriptor b = boost::add_vertex(g);
64 vertex_descriptor c = boost::add_vertex(g);
65 vertex_descriptor d = boost::add_vertex(g);
66 vertex_descriptor e = boost::add_vertex(g);
67 boost::add_edge(a, b, g);
68 boost::add_edge(a, c, g);
69 boost::add_edge(a, d, g);
70 boost::add_edge(b, c, g);
71 boost::add_edge(b, d, g);
72 boost::add_edge(c, d, g);
73 boost::add_edge(a, e, g);
74 boost::add_edge(c, e, g);
75 boost::add_edge(d, e, g);
77 BOOST_AUTO(edge_weight_map, get(edge_weight, g));
78 graph_traits<graph_type>::edge_iterator eit, eit_end;
79 for (tie(eit, eit_end) = edges(g); eit != eit_end; ++eit)
81 edge_weight_map[*eit] = 1;
87 lc.
color_num(limbo::algorithms::coloring::LPColoring<graph_type>::THREE);
89 printf(
"solved in %u LP iterations\n", lc.
lp_iters());
100 std::vector<vertex_descriptor> vertex_set;
101 std::vector< std::pair<vertex_descriptor, vertex_descriptor> > edge_set;
102 generate_random_graph(g, N, N * 2, gen,
103 std::back_inserter(vertex_set),
104 std::back_inserter(edge_set));
105 BOOST_AUTO(edge_weight_map, get(edge_weight, g));
107 graph_traits<graph_type>::edge_iterator eit, eit_end;
108 for (tie(eit, eit_end) = edges(g); eit != eit_end; ++eit, ++i)
109 edge_weight_map[*eit] = 1;
114 lc.
color_num(limbo::algorithms::coloring::LPColoring<graph_type>::FOUR);
116 printf(
"solved in %u LP iterations\n", lc.
lp_iters());
125 ifstream in (filename.c_str());
129 typedef adjacency_list<vecS, vecS, undirectedS,
130 property<vertex_index_t, std::size_t, property<vertex_color_t, int, property<vertex_name_t, std::size_t> > >,
131 property<edge_index_t, std::size_t, property<edge_weight_t, int> >,
132 property<graph_name_t, string> > tmp_graph_type;
134 dynamic_properties tmpdp;
135 tmpdp.property(
"node_id", get(vertex_name, tmpg));
136 tmpdp.property(
"label", get(vertex_name, tmpg));
137 tmpdp.property(
"weight", get(edge_weight, tmpg));
138 tmpdp.property(
"label", get(edge_weight, tmpg));
139 limboAssert(read_graphviz(in, tmpg, tmpdp,
"node_id"));
142 graph_type g (num_vertices(tmpg));
143 graph_traits<tmp_graph_type>::vertex_iterator vit, vit_end;
144 for (tie(vit, vit_end) = vertices(tmpg); vit != vit_end; ++vit)
146 size_t name = get(vertex_name, tmpg, *vit);
147 int color = get(vertex_color, tmpg, *vit);
148 put(vertex_color, g, (vertex_descriptor)name, color);
151 graph_traits<tmp_graph_type>::edge_iterator eit, eit_end;
152 for (tie(eit, eit_end) = edges(tmpg); eit != eit_end; ++eit)
154 size_t s_name = get(vertex_name, tmpg, source(*eit, tmpg));
155 size_t t_name = get(vertex_name, tmpg, target(*eit, tmpg));
156 pair<edge_descriptor, bool> pe = add_edge(s_name, t_name, g);
158 int weight = get(edge_weight, g, *eit);
159 put(edge_weight, g, pe.first, weight);
162#ifdef DEBUG_LPCOLORING
163 dynamic_properties dp;
164 dp.property(
"id", get(vertex_index, g));
165 dp.property(
"node_id", get(vertex_index, g));
166 dp.property(
"label", get(vertex_index, g));
167 dp.property(
"weight", get(edge_weight, g));
168 dp.property(
"label", get(edge_weight, g));
169 ofstream out (
"graph_init.gv");
170 write_graphviz_dp(out, g, dp,
string(
"id"));
172 system(
"dot -Tpdf graph_init.gv -o graph_init.pdf");
178 lc.
color_num(limbo::algorithms::coloring::LPColoring<graph_type>::THREE);
180 printf(
"solved in %u LP iterations\n", lc.
lp_iters());