15 #ifndef VRP_BOOST_INCLUDED
16 #define VRP_BOOST_INCLUDED
27 #include <boost/graph/graphviz.hpp>
28 #include <boost/graph/graph_utility.hpp>
29 #include <boost/graph/adjacency_list.hpp>
30 #include <boost/graph/connected_components.hpp>
31 #include <boost/graph/kruskal_min_spanning_tree.hpp>
32 using namespace boost;
35 typedef property<edge_weight_t, double,
37 typedef adjacency_list<vecS, vecS, undirectedS,
45 template <
class EdgeWeight >
49 template <
class VertexOrEdge>
50 void operator()(ostream & out,
const VertexOrEdge & e)
const {
51 if(weight[e] >= 0.9999999)
52 out <<
"[style=solid]";
54 out <<
"[label=\"" << weight[e] <<
"\", stype=dashed]";
59 template <
class EdgeWeight >
73 : demand(vertex_wt) {}
74 template <
class VertexOrEdge>
75 void operator()(ostream & out,
const VertexOrEdge & v)
const {
77 out <<
" [style=filled, fillcolor=black]";
79 out <<
" [label=\"" << v <<
" : "
80 << demand[v] <<
"\" width=\"0.5\" height=\"0.5\"]";
110 const double tol = 1.0e-6){
117 property_map<Graph, edge_weight_t>::type e_weight
118 =
get(edge_weight, m_sg);
119 property_map<Graph, edge_index_t>::type e_index
120 =
get(edge_index, m_sg);
121 graph_traits<Graph>::edge_descriptor ed;
bool inserted;
125 for (c = 0; c < len; ++c) {
130 if(uv.first == 0 || uv.second == 0){
131 m_depotDegree += val[c];
134 tie(ed, inserted) = add_edge(uv.first, uv.second, m_sg);
135 e_weight[ed] = val[c];
166 const int * vertexWt,
167 const Graph & g)
const {
172 printf(
"PrintDotFile fileName = %s\n", fileName.c_str());
174 map<string, string> graph_attr, vertex_attr, edge_attr;
175 graph_attr [
"fontsize"] =
"20";
177 vertex_attr[
"fontsize"] =
"20";
178 vertex_attr[
"shape"] =
"circle";
180 edge_attr [
"style"] =
"dotted";
181 edge_attr [
"len"] =
"1.7";
182 edge_attr [
"fontsize"] =
"20";
187 write_graphviz(os, g,
190 make_graph_attributes_writer(graph_attr,
215 return connected_components(m_sg, &component[0]);
219 vector<int> & component){
220 return connected_components(g, &component[0]);
224 return degree(nodeIndex, m_sg);
228 return m_depotDegree;
void printGraph(const Graph &g) const
sg_label_writer< EdgeWeight > sg_make_label_writer(EdgeWeight e)
adjacency_list< vecS, vecS, undirectedS, no_property, edge_prop > Graph
void buildSubGraph(const int len, const double *val, const double tol=1.0e-6)
pair< int, int > UtilBothEndsU(const int index)
void printDotFile(const string &fileName, const int *vertexWt, const Graph &g) const
int findConnectedComponents(vector< int > &component)
void copyGraph(const Graph &gFrom, Graph &gTo)
void operator()(ostream &out, const VertexOrEdge &e) const
void UtilOpenFile(ifstream &fs, const char *fileName)
sg_label_writer_vertex sg_make_label_writer_vertex(const int *vertex_wt)
sg_label_writer_vertex(const int *vertex_wt)
property< edge_weight_t, double, property< edge_index_t, int > > edge_prop
int findConnectedComponents(Graph &g, vector< int > &component)
void clearSubGraph(Graph &g)
void clearVertex(const int vertex, Graph &g)
sg_label_writer(EdgeWeight e_)
void operator()(ostream &out, const VertexOrEdge &v) const
int getDegree(const int nodeIndex)