ROSE 0.11.145.147
Classes
Sawyer::Boost Namespace Reference

Description

Boost Graph Library API for Sawyer::Container::Boost.

Including this header into a program will allow a Sawyer::Container::Graph to be accessed via the Boost Graph Library (BGL) API. Sawyer mutble graphs implement the following BGL concepts:

Const graphs implement the same concepts except MutablePropertyGraph and MutableGraph.

Vertex and edge iterators in the BGL domain map to VertexOuterIterator and EdgeOuterIterator types, which are defined in this namespace and have implicit conversions from Sawyer::Container::Graph::VertexIterator and Sawyer::Container::Graph::EdgeIterator. There are also const versions. These outer iterators produce BGL vertex_descriptor or edge_descriptor when they're dereferenced, and these descriptors are simply the Sawyer vertex and edge ID numbers.

The BGL API allows graphs to store any number of vertex and edge properties internally, but Sawyer graphs take a more STL-like approach allowing the user to specify arbitrary types for the vertices and edges. This namespace declares vertex_value_t and edge_value_t tags to access the user-supplied vertex and edge values. The vertex_id_t and edge_id_t tags can be used to access the ID properties that Sawyer automatically maintains for vertices and edges. BGL external properties have no such restrictions and can be used exactly as advertised in the BGL documentation.

The tests/Container/graphBoost.C file contains examples of using Sawyer graphs with the BGL API.

Classes

class  ConstEdgeIdPropertyMap
 
class  ConstEdgeOuterIterator
 
class  ConstEdgePropertyMap
 
class  ConstVertexIdPropertyMap
 
class  ConstVertexOuterIterator
 
class  ConstVertexPropertyMap
 
struct  edge_id_t
 
struct  edge_value_t
 
class  EdgeOuterIterator
 
class  EdgePropertyMap
 
struct  vertex_id_t
 
struct  vertex_value_t
 
class  VertexOuterIterator
 
class  VertexPropertyMap
 

Functions

template<class SawyerGraph , class BoostGraph >
void sawyerGraphToBoostGraph (const SawyerGraph &sg, BoostGraph &bg)
 Convert a Sawyer graph to a Boost graph.
 
template<class SawyerGraph , class BoostGraph >
BoostGraph sawyerGraphToBoostGraph (const SawyerGraph &sg)
 Convert a Sawyer graph to a Boost graph.
 

Function Documentation

◆ sawyerGraphToBoostGraph() [1/2]

template<class SawyerGraph , class BoostGraph >
void Sawyer::Boost::sawyerGraphToBoostGraph ( const SawyerGraph &  sg,
BoostGraph &  bg 
)

Convert a Sawyer graph to a Boost graph.

Although Sawyer graphs can be used with the algorithms in the Boost Graph Library, doing so is often quite messy since even minor problems result in error messages that are many kilobytes in length due to BGL's extensive use of templates. For instance, trying to invoke certain BGL algorithms on a reference to a const graph is an error (even though conceptually it should be possible) and the multi-line 1200-character error message from GCC makes no clear mention of the fact that a const reference is used where a non-const is expected. Also, BGL's use of "properties" to represent values stored in Sawyer Graph vertices and/or edges, or values stored in separate lookup tables, is overly complex since it's trying to be as general as possible.

Therefore, sometimes it's easier to just create a boot graph and invoke the BGL algorithm on the boost graph with some external properties. That way the user can almost cut-n-paste from BGL example code.

This method creates a BGL adjacency_list graph from a Sawyer graph. The vertices of the BGL graph must be stored in a vector (boost::vecS) and will have the same indices as the vertex ID numbers in the Sawyer graph. No user-defined vertex or edge data is copied into the BGL graph; only connectivity information is copied.

The one-argument version returns a new BGL graph of specified type; the two-argument version returns the BGL graph in the second argument.

Definition at line 83 of file GraphBoost.h.

Referenced by sawyerGraphToBoostGraph().

◆ sawyerGraphToBoostGraph() [2/2]

template<class SawyerGraph , class BoostGraph >
BoostGraph Sawyer::Boost::sawyerGraphToBoostGraph ( const SawyerGraph &  sg)

Convert a Sawyer graph to a Boost graph.

Although Sawyer graphs can be used with the algorithms in the Boost Graph Library, doing so is often quite messy since even minor problems result in error messages that are many kilobytes in length due to BGL's extensive use of templates. For instance, trying to invoke certain BGL algorithms on a reference to a const graph is an error (even though conceptually it should be possible) and the multi-line 1200-character error message from GCC makes no clear mention of the fact that a const reference is used where a non-const is expected. Also, BGL's use of "properties" to represent values stored in Sawyer Graph vertices and/or edges, or values stored in separate lookup tables, is overly complex since it's trying to be as general as possible.

Therefore, sometimes it's easier to just create a boot graph and invoke the BGL algorithm on the boost graph with some external properties. That way the user can almost cut-n-paste from BGL example code.

This method creates a BGL adjacency_list graph from a Sawyer graph. The vertices of the BGL graph must be stored in a vector (boost::vecS) and will have the same indices as the vertex ID numbers in the Sawyer graph. No user-defined vertex or edge data is copied into the BGL graph; only connectivity information is copied.

The one-argument version returns a new BGL graph of specified type; the two-argument version returns the BGL graph in the second argument.

Definition at line 90 of file GraphBoost.h.

References sawyerGraphToBoostGraph().