57 vertex_descriptor a = boost::add_vertex(g);
58 vertex_descriptor b = boost::add_vertex(g);
59 vertex_descriptor c = boost::add_vertex(g);
60 vertex_descriptor d = boost::add_vertex(g);
61 vertex_descriptor e = boost::add_vertex(g);
62 boost::add_edge(a, b, g);
63 boost::add_edge(a, c, g);
64 boost::add_edge(a, d, g);
65 boost::add_edge(a, e, g);
66 boost::add_edge(b, c, g);
67 boost::add_edge(b, e, g);
68 boost::add_edge(c, d, g);
69 boost::add_edge(d, e, g);
71 BOOST_AUTO(edge_weight_map, get(edge_weight, g));
72 graph_traits<graph_type>::edge_iterator eit, eit_end;
73 for (tie(eit, eit_end) = edges(g); eit != eit_end; ++eit)
75 if (source(*eit, g) != a || target(*eit, g) != d)
76 edge_weight_map[*eit] = 1;
78 edge_weight_map[*eit] = -1;
85 lc.
color_num(limbo::algorithms::coloring::SDPColoringCsdp<graph_type>::THREE);
95 std::vector<vertex_descriptor> vertex_set;
96 std::vector< std::pair<vertex_descriptor, vertex_descriptor> > edge_set;
97 generate_random_graph(g, N, N * 2, gen,
98 std::back_inserter(vertex_set),
99 std::back_inserter(edge_set));
100 BOOST_AUTO(edge_weight_map, get(edge_weight, g));
102 graph_traits<graph_type>::edge_iterator eit, eit_end;
103 for (tie(eit, eit_end) = edges(g); eit != eit_end; ++eit, ++i)
107 edge_weight_map[*eit] = -1;
110 edge_weight_map[*eit] = 1;
117 lc.
color_num(limbo::algorithms::coloring::SDPColoringCsdp<graph_type>::THREE);
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 std::cout <<
"read_graphviz\n";
140 limboAssert(read_graphviz(in, tmpg, tmpdp,
"node_id"));
143 graph_type g (num_vertices(tmpg));
144 graph_traits<tmp_graph_type>::vertex_iterator vit, vit_end;
145 for (tie(vit, vit_end) = vertices(tmpg); vit != vit_end; ++vit)
147 size_t name = get(vertex_name, tmpg, *vit);
148 int color = get(vertex_color, tmpg, *vit);
149 put(vertex_color, g, (vertex_descriptor)name, color);
152 graph_traits<tmp_graph_type>::edge_iterator eit, eit_end;
153 for (tie(eit, eit_end) = edges(tmpg); eit != eit_end; ++eit)
155 size_t s_name = get(vertex_name, tmpg, source(*eit, tmpg));
156 size_t t_name = get(vertex_name, tmpg, target(*eit, tmpg));
157 pair<edge_descriptor, bool> pe = add_edge(s_name, t_name, g);
159 int weight = get(edge_weight, g, *eit);
160 put(edge_weight, g, pe.first, weight);
163#ifdef DEBUG_SDPCOLORING
164 dynamic_properties dp;
165 dp.property(
"id", get(vertex_index, g));
166 dp.property(
"node_id", get(vertex_index, g));
167 dp.property(
"label", get(vertex_index, g));
168 dp.property(
"weight", get(edge_weight, g));
169 dp.property(
"label", get(edge_weight, g));
170 ofstream out (
"graph_init.gv");
171 write_graphviz_dp(out, g, dp,
string(
"id"));
173 system(
"dot -Tpdf graph_init.gv -o graph_init.pdf");
180 lc.
color_num(limbo::algorithms::coloring::SDPColoringCsdp<graph_type>::THREE);