JohnCoconut / boost_graph_cookbook_1

A well-connected C++14 Boost.Graph tutorial
http://richelbilderbeek.nl/CppBoostGraphTutorial.htm
GNU General Public License v3.0
0 stars 0 forks source link

use graph_traits whenver possible #8

Open JohnCoconut opened 6 years ago

JohnCoconut commented 6 years ago

We have two ways of getting graph attributes in the tutorial. For example, vertex_descriptor

using vd = typename graph::vertex_descriptor;

using vd = typename boost::graph_traits<graph>::vertex_descriptor;

The difference is graph_traits is able to store type information externally, and it's easy to customize it by template partial specialization.

richelbilderbeek commented 6 years ago

Sounds like a great suggestion. Feel encouraged to change code to use graph_traits :+1: