This is source code:
//====== file_dep_graph.h ======
/*
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <numeric>
using namespace std;
#include
#include
#include
#include
using namespace boost;
*/
//==============================
#include "file_dep_graph.h"
typedef string Name;
typedef float CompileCost;
namespace boost {
enum vertex_compile_cost_t { vertex_compile_cost = 111 };
BOOST_INSTALL_PROPERTY( vertex, compile_cost );
}
typedef adjacency_list<
listS,
listS,
directedS,
property > > >,
property
file_dep_graph2;
typedef graph_traits::vertex_descriptor vertex_d;
typedef graph_traits::vertex_iterator vertex_i;
typedef graph_traits::edge_descriptor edge_d;
typedef graph_traits::edge_iterator edge_i;
typedef property_map::type name_map_t;
typedef property_map::type
compile_cost_map_t;
typedef property_map::type
distance_map_t;
typedef property_map::type color_map_t;
typedef map Name2Vertex;
typedef pair TargetProperties;
typedef vector<TargetProperties> TargetsProperties;
typedef istream_iterator<TargetProperties> TargetsPropertiesInputIterator;
typedef ostream_iterator<TargetProperties> TargetsPropertiesOutputIterator;
namespace std {
istream& operator>> ( istream& is, TargetProperties& target_propertices )
{
is >> target_propertices.first >> target_propertices.second;
return is;
}
ostream& operator<< ( ostream& os, const TargetProperties&
target_propertices )
{
os << target_propertices.first << ' ' << target_propertices.second;
return os;
}
}
typedef pair Dependency;
typedef vector<Dependency> Dependencies;
typedef istream_iterator<Dependency> DependenciesInputIterator;
typedef ostream_iterator<Dependency> DependenciesOutputIterator;
namespace std {
istream& operator>> ( istream& is, Dependency& dependency )
{
is >> dependency.first >> dependency.second;
return is;
}
ostream& operator<< ( ostream& os, const Dependency& dependency)
{
os << dependency.first << ' ' << dependency.second;
return os;
}
}
template
void dfs_v2( const Graph& g,
typename graph_traits<Graph>::vertex_desciptor u,
ColorMap color, Visitor vis )
{
typedef typename property_traits<ColorMap>::value_type color_type;
typedef color_traits ColorT;
color[ u ] = ColorT::gray();
vis.discover_vertex( u, g );
typename graph_traits<Graph>::out_edge_iterator ei, ei_end;
for( tie( ei, ei_end ) = out_edges( u, g ); ei != ei_end; ei++ )
if( color[ target( *ei, g ) ] = ColorT::white() )
{
vis.tree_edge( *ei, g );
dfs_v2( g, target( *ei, g ), color, vis );
}
else
if( color[ target( *ei, g ) ] == ColorT::gray() )
vis.back_edge( *ei, g );
else
vis.forward_or_cross_edge( *ei, g );
color[ u ] = ColorT::black();
vis.finish_vertex( u, g );
}
template
void generic_dfs_v2( const Graph& g, Visitor vis, ColorMap color )
{
typedef color_traits ColorT;
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for( tie( vi, vi_end ) = vertices( g ); vi != vi_end; vi++ )
color[ *vi ] = ColorT::white();
for( tie( vi, vi_end ) = vertices( g ); vi != vi_end; vi++ )
if( color[ *vi ] == ColorT::white() )
dfs_v2( g, *vi, color, vis );
}
struct default_dfs_visitor {
template
void discover_vertex( V, const G& ) {}
template
void tree_edge( E, const G& ) {}
template
void back_edge( E, const G& ) {}
template
void forward_or_cross_edge( E, const G& ) {}
template
void finish_vertex( V, const G& ) {}
};
template <typename OutputIterator>
struct topo_visitor : public default_dfs_visitor {
topo_visitor( OutputIterator& order )
:topo_order( order ) {}
template <typename Graph>
void finish_vertex( typename graph_traits<Graph>::vertex_descriptor u,
const Graph& )
{
*topo_order++ = u;
}
OutputIterator& topo_order;
};
template
void topo_sort( const Graph& g, OutputIterator topo_order, ColorMap color )
{
topo_visitor<OutputIterator> vis( topo_order );
generic_dfs_v2( g, vis, color );
}
int main()
{
// ====== input data from file =======
ifstream ifile( "makefile_target_properties.dat" );
TargetsPropertiesInputIterator it( ifile ), it_end;
TargetsProperties targets_properties( it, it_end );
ifile.close();
ifstream ifile_dep( "makefile_dependencies.dat" );
DependenciesInputIterator it_dep( ifile_dep ), it_dep_end;
Dependencies dependencies( it_dep, it_dep_end );
ifile_dep.close();
// ======= create graph ======
file_dep_graph2 g( targets_properties.size() );
vertex_i vi, vi_end;
tie( vi, vi_end ) = vertices( g );
Name2Vertex name2vertex;
for( int i = 0; vi != vi_end; vi++, i++ )
name2vertex[ targets_properties[ i ].first ] = *vi;
for( int i = 0; i < dependencies.size(); i++ )
add_edge( name2vertex[ dependencies[ i ].first ],
name2vertex[ dependencies[ i ].second ], g );
// ======== set properties ========
tie( vi, vi_end ) = vertices( g );
name_map_t name_map = get( vertex_name, g ) ;
for( int i = 0; vi != vi_end; vi++, i++ )
name_map[ *vi ] = targets_properties[ i ].first;
tie( vi, vi_end ) = vertices( g );
compile_cost_map_t compile_cost_map = get( vertex_compile_cost, g );
for( int i = 0; vi != vi_end; vi++, i++ )
compile_cost_map[ *vi ] = targets_properties[ i ].second;
graph_property_iter_range::iterator ni,
ni_end;
tie( ni, ni_end ) = get_property_iter_range( g, vertex_name );
for( ;ni != ni_end; ni++ )
cout << *ni << endl;
graph_property_iter_range::iterator
ci, ci_end;
tie( ci, ci_end ) = get_property_iter_range( g, vertex_compile_cost );
cout << accumulate( ci, ci_end, 0.0 ) << endl;
vector order( num_vertices( g ) );
color_map_t color_map = get( vertex_color, g );
topo_sort( g, order.rbegin(), color_map );
return 0;
}
========= complied code =========
[root@zml file_dep_graph]#g++ -o file_dep_graph2 file_dep_graph2.cpp
file_dep_graph2.cpp: In function 'void generic_dfs_v2(const Graph&,
Visitor, ColorMap) [with Graph = boost::adjacency_list,
boost::property > > >, boost::property, boost::no_property, boost::listS>, Visitor =
topo_visitor > > > >, ColorMap =
boost::adj_list_vertex_property_map,
boost::property > > >, boost::property, boost::no_property, boost::listS>,
boost::default_color_type, boost::default_color_type&,
boost::vertex_color_t>]':
file_dep_graph2.cpp:165: instantiated from 'void topo_sort(const Graph&,
OutputIterator, ColorMap) [with Graph = file_dep_graph2, OutputIterator =
std::reverse_iterator<__gnu_cxx::__normal_iterator > > >, ColorMap =
boost::adj_list_vertex_property_map,
boost::property > > >, boost::property, boost::no_property, boost::listS>,
boost::default_color_type, boost::default_color_type&,
boost::vertex_color_t>]'
file_dep_graph2.cpp:225: instantiated from here
file_dep_graph2.cpp:132: error: no matching function for call to
'dfs_v2(const boost::adjacency_list,
boost::property > > >, boost::property, boost::no_property, boost::listS>&, void*&,
boost::adj_list_vertex_property_map,
boost::property > > >, boost::property, boost::no_property, boost::listS>,
boost::default_color_type, boost::default_color_type&,
boost::vertex_color_t>&,
topo_visitor > > > >&)'
How can I solve this error? Anybody can help me?