Reset Extensions and Node Extraction for flow::graph

Summary

Extensions to the flow graph classes to support traversal and extraction of graph nodes:

CAUTION

The use of register_predecessor and register_successor to build graphs has been deprecated for flow::graph. Where n1.register_successor(n2) was used, replace with make_edge(n1,n2). For the preview feature to work, make_edge/remove_edge must be used to construct the graph.

Header

#define TBB_PREVIEW_FLOW_GRAPH_FEATURES 1
#include "tbb/flow_graph.h"
         

Additional syntax for graph nodes

CAUTION

The methods added to the graph_node class are not thread-safe. The graph should not be active when they are used.

graph_nodes are extended with the following typedefs and per-instance methods:

namespace tbb {
namespace flow {
  class graph_node {
  public:
    typedef implementation-defined predecessor_type;         // all but source_node
    typedef implementation-defined predecessor_list_type;  // all but source_node
    typedef implementation-defined successor_type;
    typedef implementation-defined successor_list_type;

    size_t predecessor_count();  // all but source_node
    size_t successor_count();
    void   copy_predecessors(predecessor_list_type &pv);  // all but source_node
    void   copy_successors(successor_list_type &sv);
    void extract( );
  };
}
}
             
The following table provides additional information on the new members and typedefs of tbb::flow::graph_node.
Member Description
predecessor_type

Defines the type of the elements of predecessor_list_type. This type is not defined for source_node.

predecessor_list_type

Defines the type returned by copy_predecessors(). This class will have size(), begin(), end() and iterator types defined. This type is not defined for source_node.

successor_type

Defines the type of the element of successor_list_type.

successor_list_type

Defines the type returned by copy_successors(). This class will have size(), begin(), end() and iterator types defined.

size_t predecessor_count();

Returns the number of graph nodes which have been attached as predecessors to the current node with make_edge() and not removed with remove_edge() or by calling extract() or reset(rf_clear_edges). This method is not defined for source_node.

size_t successor_count();

Returns the number of graph nodes which have been attached as successors to the current node with make_edge() and not removed with remove_edge() or by calling extract() or reset(rf_clear_edges) .

void copy_predecessors(predecessor_list_type &pv);

Returns a data structure containing pointers to all the predecessors of the node. This method is not defined for source_node.

void copy_successors(successor_list_type &sv);

Returns a data structure containing pointers to all the successors of the node.

void extract( )

Removes all edges to the node.

See Also