e Graph> _coverage :: graph_coverage (const Graph & graph)
{std :: pair edges_range=boost :: edges (graph); (edges_range.first!=edges_range.second)
{_t source_vertex=boost :: source (* edges_range.first, graph); _t target_vertex=boost :: target (* edges_range.first, graph); _covered_edges [edge_id (source_vertex, target_vertex)] =false;
+ + edges_range.first;
}
}
# endif / / GRAPH_COVERAGE_H_
graph_coverage.cpp
# include «stdafx.h»
# include «graph_coverage.h» utils
{
/*--------------------------------------------------------------------------------------------*/edges_list_from_path(const std :: list & path, std :: list * out)
{(path.empty ()); :: list :: const_iterator path_it=path.begin (); :: list :: const_iterator path_end=path.end () ; _t current_vertex=* path_it;
+ + path_it; (path_it!=path_end)
{_t next_vertex=* path_it;> push_back (edge_id (current_vertex, next_vertex)); _vertex=next_vertex;
+ + path_it;
}
}
/*--------------------------------------------------------------------------------------------*/
}
/////////////////////////////////////////////////////////////////////////////////////////////////////_t graph_coverage :: aditional_coverage_for_path (std :: list path) const
{:: list edges_of_path; :: edges_list_from_path (path, & edges_of_path); _t coverage=0; _FOREACH (const edge_id & edge_of_path, edges_of_path)
{_map :: const_iterator it=m_covered_edges.find (edge_of_path); (it!=m_covered_edges.end ()); (! it-> second)
{/ / edge not covered yet
+ + coverage;
}
} coverage;
}
/*-------------------------------------------------------------------------------------------------*/graph_coverage::fully_covered() const
{result=true; _FOREACH (const coverage_map :: value_type & edge_coverage, m_covered_edges)
{/ / Cover all edges in graph=result && edge_coverage.second;
} result;
}
/*-------------------------------------------------------------------------------------------------*/graph_coverage::add_coverage_for_path(const std :: list & path)
{:: list edges_of_path; :: edges_list_from_path (path, & edges_of_path); _FOREACH (const edge_id & edge_of_path, edges_of_path)
{/ / Cover all edges from path_covered_edges [edge_of_path]=true;
}
}
/*-------------------------------------------------------------------------------------------------*/
main.cpp
<...