{"action":"created","issue":{"url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/26","labels_url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/26/comments","events_url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/26/events","html_url":"https://github.com/richelbilderbeek/BoostGraphTutorial/issues/26","id":124195635,"number":26,"title":"Add feedback from Reddit","user":{"login":"richelbilderbeek","id":2098230,"avatar_url":"https://avatars.githubusercontent.com/u/2098230?v=3","gravatar_id":"","url":"https://api.github.com/users/richelbilderbeek","html_url":"https://github.com/richelbilderbeek","followers_url":"https://api.github.com/users/richelbilderbeek/followers","following_url":"https://api.github.com/users/richelbilderbeek/following{/other_user}","gists_url":"https://api.github.com/users/richelbilderbeek/gists{/gist_id}","starred_url":"https://api.github.com/users/richelbilderbeek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richelbilderbeek/subscriptions","organizations_url":"https://api.github.com/users/richelbilderbeek/orgs","repos_url":"https://api.github.com/users/richelbilderbeek/repos","events_url":"https://api.github.com/users/richelbilderbeek/events{/privacy}","received_events_url":"https://api.github.com/users/richelbilderbeek/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-29T11:05:19Z","updated_at":"2015-12-29T15:11:47Z","closed_at":"2015-12-29T15:11:47Z","body":"Here is the thread:\r\n\r\nhttps://www.reddit.com/r/cpp/comments/3xw5q0/a_wellconnected_c11_boostgraph_tutorial/\r\n\r\nFrom mat69:\r\n\r\n* You often create vectors of vertices/edges/names. When using unfiltered graphs you could use reserve in combination with num_edges, num_vertices.\r\n* Sometimes, like when retrieving all the vertex names you first retrieve a vector of vertices to then iterate over them. In this case it is way more efficient to iterate directly over vertices() and avoiding the intermediate vector alltogether.\r\n* You are not consistent in the way you access property maps. Sometimes you use my_map[XYZ] and other times get. To have flexible code you should always use get and put. That way you can change the vertex storage from vector to something else, without having to adapt all the other code.\r\n* You should also mention the complexity of operations. The way you retrieve a vertex by name is O(n). I guess in most use cases it will be more efficient to have an std::unordered_map<std::string, MyVertex> and doing a lookup instead.\r\n* You could use the standard algorithms in some occasions, for example when you search for a vertex by its name (5.2):\r\n\r\n```\r\n    auto vip = vertices(g); auto it = std::find_if(vip.first, vip.second, [&](const VertexDescriptor &vd) { return get(vertex_name_map, vd) == name; });\r\n```\r\n\r\n* You do not reuse your own functions, for example, you have an own function to retrieve the out degree of a vertex and then you have the same function when just a name was provided. I think a more natural way would be to retrieve the vertex given a name and to then call the out degree function with the retrieved vertex.\r\n\r\n\r\nFrom danieljh:\r\n\r\n * Regarding the vertices and edges functions: I enjoy using Boost.Range with them, as they return a pair of first,last-iterators. Combining this with range adaptors and lambdas, Boost.Graph code can get really modern and readable, such as:\r\n\r\n```\r\nauto weights = edges(graph) | transformed(to_weights) | filtered(is_non_negative);\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/comments/167807843","html_url":"https://github.com/richelbilderbeek/BoostGraphTutorial/issues/26#issuecomment-167807843","issue_url":"https://api.github.com/repos/richelbilderbeek/BoostGraphTutorial/issues/26","id":167807843,"user":{"login":"richelbilderbeek","id":2098230,"avatar_url":"https://avatars.githubusercontent.com/u/2098230?v=3","gravatar_id":"","url":"https://api.github.com/users/richelbilderbeek","html_url":"https://github.com/richelbilderbeek","followers_url":"https://api.github.com/users/richelbilderbeek/followers","following_url":"https://api.github.com/users/richelbilderbeek/following{/other_user}","gists_url":"https://api.github.com/users/richelbilderbeek/gists{/gist_id}","starred_url":"https://api.github.com/users/richelbilderbeek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richelbilderbeek/subscriptions","organizations_url":"https://api.github.com/users/richelbilderbeek/orgs","repos_url":"https://api.github.com/users/richelbilderbeek/repos","events_url":"https://api.github.com/users/richelbilderbeek/events{/privacy}","received_events_url":"https://api.github.com/users/richelbilderbeek/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T15:11:47Z","updated_at":"2015-12-29T15:11:47Z","body":"Moved to seperate Issues"}}