Skip to content

Commit

Permalink
Compile the SGB examples. (#87)
Browse files Browse the repository at this point in the history
Works fine with c++11, thanks!

System: (K)Ubuntu 16.04 LTS
Compiler: g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

Try to 'g++ -c' the four SGB examples girth.cpp, miles_span.cpp,
roget_components.cpp, and topo-sort-with-sgb.cpp.

(1) SGB 2002-01-30 changed the 'Associated Press scores' from 'ap0' and
'ap1' to 'ap'. This preprocessor macro (sic!) collides with numerous
function parameters in 'named_function_params.hpp'. '#undef'ining the
macro doesn't break the BGL examples.

(2) girth.cpp fails because of a missing 'null_vertex()' function.

(3) roget_components.cpp invokes 'strncmp()' from the C library.

(4) topo-sort-with-sgb.cpp hickups because of a missing 'vertices()'
function. Following roget_components.cpp and putting the collective
SGB header up front fixes this.
  • Loading branch information
ascherer authored and Belcourt committed May 27, 2017
1 parent eda383e commit 74115a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion example/roget_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <boost/graph/stanford_graph.hpp>
#include <boost/graph/strong_components.hpp>
Expand Down
2 changes: 1 addition & 1 deletion example/topo-sort-with-sgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <vector>
#include <string>
#include <iostream>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/stanford_graph.hpp>
#include <boost/graph/topological_sort.hpp>

int
main()
Expand Down
8 changes: 8 additions & 0 deletions include/boost/graph/stanford_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extern "C" {
#include <gb_books.h> /* graphs based on literature */
#include <gb_econ.h> /* graphs based on economic data */
#include <gb_games.h> /* graphs based on football scores */
#undef ap /* avoid name clash with BGL parameter */
// ap ==> Vertex::u.I
#include <gb_gates.h> /* graphs based on logic circuits */
#undef val /* avoid name clash with g++ headerfile stl_tempbuf.h */
// val ==> Vertex::x.I
Expand Down Expand Up @@ -92,6 +94,9 @@ namespace boost {
typedef directed_tag directed_category;
typedef sgb_traversal_tag traversal_category;
typedef allow_parallel_edge_tag edge_parallel_category;
/** Return a null descriptor */
static vertex_descriptor null_vertex()
{ return NULL; }
};
template <> struct graph_traits<sgb_const_graph_ptr> {
typedef Vertex* vertex_descriptor;
Expand All @@ -107,6 +112,9 @@ namespace boost {
typedef directed_tag directed_category;
typedef sgb_traversal_tag traversal_category;
typedef allow_parallel_edge_tag edge_parallel_category;
/** Return a null descriptor */
static vertex_descriptor null_vertex()
{ return NULL; }
};
}

Expand Down

0 comments on commit 74115a2

Please sign in to comment.