I use below mentioned code to make colour edges using boost graph api:
#include <iostream>
#include <string>
#include <boost/graph/directed_graph.hpp>
#include <boost/graph/labeled_graph.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
using namespace std;
template < typename Graph, typename VertexNameMap, typename EdgeNameMap > void
print_dependencies(std::ostream & out, const Graph & g,
VertexNameMap name_map,EdgeNameMap edge_map)
{
//property_map<Graph, edge_name_t>::type name = get(edge_map, g);
typename graph_traits < Graph >::edge_iterator ei, ei_end;
cout<<"digraph G {"<<"\n";
//for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
// out << get(name_map, source(*ei, g)) <<" ;" <<std::endl;
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
out << get(name_map, source(*ei, g)) << "->"
<< get(name_map, target(*ei, g)) << " [color= "<<edge_map[*ei] <<"]"<<" ;" <<std::endl;
cout<<"}"<<"\n";
}
int main() {
using namespace boost;
typedef boost::adjacency_list
<
//Store all edges as a std::vector
boost::vecS,
//Store all vertices in a std::vector
boost::vecS,
//Relations are both ways (in this example)
//(note: but you can freely change it to boost::directedS)
boost::directedS,
//All vertices are person names of type std::string
boost::property<boost::vertex_name_t,std::string>,
//All edges are weights equal to the encounter frequencies
// boost::property<boost::edge_weight_t,double>,
boost::property<boost::edge_name_t,std::string>,
//Graph itself has a std::string name
// boost::property< vertex_color_t, default_color_type >,
boost::property<boost::graph_name_t,std::string>
> Graph;
Graph g;
typedef boost::graph_traits<Graph>::edge_descriptor ed;
typedef std::pair<ed, bool> edgeName;
typedef property<edge_name_t, string> EdgeProperty;
string ab = "test";
string cd = "hello";
//All vertex names
//Note: cannot use spaces
std::vector<std::string> names;
names.push_back("MrA");
names.push_back("Mrs_B");
names.push_back("Dr_C");
names.push_back("Prof_D");
// Graph::vertex_descriptor
const Graph::vertex_descriptor v0 = boost::add_vertex(names[0],g);
const Graph::vertex_descriptor v1 = boost::add_vertex(names[1],g);
const Graph::vertex_descriptor v2 = boost::add_vertex(names[2],g);
const Graph::vertex_descriptor v3 = boost::add_vertex(names[3],g);
const Graph::vertex_descriptor v4 = boost::add_vertex(ab,g);
boost::add_vertex(cd,g);
boost::add_edge(v0, v1,EdgeProperty("red"), g);
boost::add_edge(v1,v2,EdgeProperty("yellow"),g);
boost::add_edge(v2,v3,EdgeProperty("red"),g);
boost::add_edge(v3,v4,EdgeProperty("green"),g);
boost::add_edge(0,5,EdgeProperty("blue"),g);
//write_graphviz(cout, g);
print_dependencies(std::cout, g, get(vertex_name, g), get(edge_name, g) );
}