@@ -50,21 +50,21 @@ void load_actor_graph(std::istream& in, ActorGraph& g)
5050 // Map from the actor numbers on this line to the actor vertices
5151 typedef tokenizer<char_separator<char > > Tok;
5252 Tok tok (line, char_separator<char >(" " ));
53- for (Tok::iterator id = tok. begin (); id != tok. end (); ++id ) {
54- int actor_id = lexical_cast<int >(* id);
55- std::map< int , Vertex>::iterator v = actors.find (actor_id);
53+ for (const auto & id : tok) {
54+ auto actor_id = lexical_cast<int >(id);
55+ auto v = actors.find (actor_id);
5656 if (v == actors.end ()) {
57- Vertex new_vertex = add_vertex (Actor (actor_id), g);
57+ auto new_vertex = add_vertex (Actor (actor_id), g);
5858 actors[actor_id] = new_vertex;
5959 actors_in_movie.push_back (new_vertex);
6060 } else {
6161 actors_in_movie.push_back (v->second );
6262 }
6363 }
6464
65- for (std::vector<Vertex>::iterator i = actors_in_movie.begin ();
65+ for (auto i = actors_in_movie.begin ();
6666 i != actors_in_movie.end (); ++i) {
67- for (std::vector<Vertex>::iterator j = i + 1 ;
67+ for (auto j = i + 1 ;
6868 j != actors_in_movie.end (); ++j) {
6969 if (!edge (*i, *j, g).second ) add_edge (*i, *j, g);
7070 }
@@ -78,14 +78,12 @@ write_pajek_graph(std::ostream& out, const Graph& g,
7878 VertexIndexMap vertex_index, VertexNameMap vertex_name)
7979{
8080 out << " *Vertices " << num_vertices (g) << ' \n ' ;
81- typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator;
82- for (vertex_iterator v = vertices (g).first ; v != vertices (g).second ; ++v) {
81+ for (auto v = vertices (g).first ; v != vertices (g).second ; ++v) {
8382 out << get (vertex_index, *v)+1 << " \" " << get (vertex_name, *v) << " \"\n " ;
8483 }
8584
8685 out << " *Edges\n " ;
87- typedef typename graph_traits<Graph>::edge_iterator edge_iterator;
88- for (edge_iterator e = edges (g).first ; e != edges (g).second ; ++e) {
86+ for (auto e = edges (g).first ; e != edges (g).second ; ++e) {
8987 out << get (vertex_index, source (*e, g))+1 << ' '
9088 << get (vertex_index, target (*e, g))+1 << " 1.0\n " ; // HACK!
9189 }
0 commit comments