14 #ifndef vtkBoostGraphAdapter_h
15 #define vtkBoostGraphAdapter_h
33 #include <boost/version.hpp>
45 struct read_write_property_map_tag;
47 #define vtkPropertyMapMacro(T, V) \
49 struct property_traits<T*> \
51 typedef V value_type; \
52 typedef V reference; \
53 typedef vtkIdType key_type; \
54 typedef read_write_property_map_tag category; \
57 inline property_traits<T*>::reference get(T* const& arr, property_traits<T*>::key_type key) \
59 return arr->GetValue(key); \
63 T* arr, property_traits<T*>::key_type key, const property_traits<T*>::value_type& value) \
65 arr->InsertValue(key, value); \
85 return arr->GetTuple1(
key);
105 return arr->GetVariantValue(
key);
113 #if defined(_MSC_VER)
124 #include <boost/config.hpp>
125 #include <boost/version.hpp>
127 #if BOOST_VERSION > 107300 && BOOST_VERSION < 107600
128 #define BOOST_ALLOW_DEPRECATED_HEADERS
129 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
132 #include <boost/graph/adjacency_iterator.hpp>
133 #include <boost/graph/graph_traits.hpp>
134 #include <boost/graph/properties.hpp>
135 #include <boost/iterator/iterator_facade.hpp>
145 :
public iterator_facade<vtk_vertex_iterator, vtkIdType, bidirectional_traversal_tag,
146 const vtkIdType&, vtkIdType>
155 const vtkIdType& dereference()
const {
return index; }
159 void increment() { index++; }
160 void decrement() { index--; }
168 :
public iterator_facade<vtk_edge_iterator, vtkEdgeType, forward_traversal_tag,
169 const vtkEdgeType&, vtkIdType>
195 if (graph !=
nullptr)
198 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
203 if (vertex < lastVertex)
244 return vertex == other.vertex && iter == other.iter;
260 while (iter !=
nullptr &&
280 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
285 if (vertex < lastVertex)
298 void RecalculateEdge()
318 :
public iterator_facade<vtk_out_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
319 const vtkEdgeType&, ptrdiff_t>
329 g->GetOutEdges(vertex, iter, nedges);
359 void RecalculateEdge()
375 :
public iterator_facade<vtk_in_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
376 const vtkEdgeType&, ptrdiff_t>
386 g->GetInEdges(vertex, iter, nedges);
416 void RecalculateEdge()
436 VTK_ABI_NAMESPACE_BEGIN
439 :
public virtual bidirectional_graph_tag
440 ,
public virtual edge_list_graph_tag
441 ,
public virtual vertex_list_graph_tag
442 ,
public virtual adjacency_graph_tag
446 VTK_ABI_NAMESPACE_END
471 #if BOOST_VERSION >= 104500
473 struct graph_property_type<
vtkGraph*>
475 typedef no_property
type;
491 #if BOOST_VERSION >= 104500
495 typedef no_property
type;
549 #if BOOST_VERSION >= 104500
552 struct graph_property_type<
vtkDirectedGraph*> : graph_property_type<vtkGraph*>
558 struct graph_property_type<
vtkDirectedGraph*
const> : graph_property_type<vtkGraph*>
587 #if BOOST_VERSION >= 104500
596 struct graph_bundle_type<
vtkDirectedGraph*
const> : graph_bundle_type<vtkGraph*>
665 #if BOOST_VERSION >= 104500
674 struct graph_property_type<
vtkUndirectedGraph*
const> : graph_property_type<vtkGraph*>
703 #if BOOST_VERSION >= 104500
761 #if BOOST_VERSION >= 104500
800 #if BOOST_VERSION >= 104500
858 #if BOOST_VERSION >= 104500
868 : graph_property_type<vtkUndirectedGraph*>
899 #if BOOST_VERSION >= 104500
967 inline std::pair<boost::graph_traits<vtkGraph*>::vertex_iterator,
982 inline std::pair<boost::graph_traits<vtkGraph*>::edge_iterator,
990 inline std::pair<boost::graph_traits<vtkGraph*>::out_edge_iterator,
995 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u,
true));
999 inline std::pair<boost::graph_traits<vtkGraph*>::in_edge_iterator,
1004 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u,
true));
1008 inline std::pair<boost::graph_traits<vtkGraph*>::adjacency_iterator,
1014 std::pair<OutEdgeIter, OutEdgeIter> out =
out_edges(u, g);
1015 return std::make_pair(Iter(out.first, &g), Iter(out.second, &g));
1052 inline std::pair<boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor,
bool>
add_edge(
1057 return std::make_pair(e,
true);
1066 inline std::pair<boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor,
bool>
add_edge(
1072 return std::make_pair(e,
true);
1077 VTK_ABI_NAMESPACE_BEGIN
1086 VTK_ABI_NAMESPACE_END
1107 VTK_ABI_NAMESPACE_BEGIN
1108 template <
typename PMap>
1124 VTK_ABI_NAMESPACE_END
1126 template <
typename PMap>
1130 return get(helper.pmap,
key.Id);
1133 template <
typename PMap>
1144 VTK_ABI_NAMESPACE_BEGIN
1145 template <
typename PMap>
1161 VTK_ABI_NAMESPACE_END
1163 template <
typename PMap>
1167 return get(helper.pmap,
key);
1170 template <
typename PMap>
1181 VTK_ABI_NAMESPACE_BEGIN
1185 VTK_ABI_NAMESPACE_END
1205 VTK_ABI_NAMESPACE_BEGIN
1206 template <
typename PMap>
1222 VTK_ABI_NAMESPACE_END
1224 template <
typename PMap>
1228 return multi.multiplier *
get(multi.pmap,
key);
1231 template <
typename PMap>
1311 #if BOOST_VERSION > 104000
1312 #include <boost/property_map/vector_property_map.hpp>
1314 #include <boost/vector_property_map.hpp>
1317 #endif // vtkBoostGraphAdapter_h
static vtkDirectedGraph * SafeDownCast(vtkObjectBase *o)
virtual vtkIdType GetNumberOfEdges()
The number of edges in the graph.
helper for the vtkGraph class that allows the graph to be distributed across multiple memory spaces...
property_traits< PMap >::reference reference
property_traits< PMap >::category category
vtkEdgeType AddEdge(vtkIdType u, vtkIdType v)
Adds a directed edge from u to v, where u and v are vertex indices, and returns a vtkEdgeType structu...
vtkGraphEdgePropertyMapHelper(PMap m)
virtual vtkInformation * GetInformation()
Set/Get the information object associated with this data object.
read_write_property_map_tag category
void put(vtkGraphPropertyMapMultiplier< PMap > multi, const typename property_traits< PMap >::key_type &key, const typename property_traits< PMap >::value_type &value)
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
Forward declaration required for Boost serialization.
vtkGraphVertexPropertyMapHelper(PMap m)
std::pair< boost::graph_traits< vtkGraph * >::out_edge_iterator, boost::graph_traits< vtkGraph * >::out_edge_iterator > out_edges(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
virtual vtkIdType GetNumberOfVertices()
The number of vertices in the graph.
vtk_out_edge_pointer_iterator out_edge_iterator
property_traits< PMap >::reference reference
vtkIdType degree_size_type
Abstract superclass for all arrays.
vtkGraphPropertyMapMultiplier(PMap m, float multi=1)
friend class iterator_core_access
property_traits< PMap >::category category
vtkIdType GetEdgeOwner(vtkIdType e_id) const
Returns owner of edge with ID e_id, by extracting top ceil(log2 P) bits of e_id.
vtkGraph_traversal_category traversal_category
directed_tag directed_category
vtk_in_edge_pointer_iterator in_edge_iterator
vtkIdType edges_size_type
dynamic, self-adjusting array of float
vtkIdType GetVertexOwner(vtkIdType v) const
Returns owner of vertex v, by extracting top ceil(log2 P) bits of v.
vtk_edge_iterator edge_iterator
std::pair< boost::graph_traits< vtkGraph * >::in_edge_iterator, boost::graph_traits< vtkGraph * >::in_edge_iterator > in_edges(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
dynamic, self-adjusting array of vtkIdType
property_traits< PMap >::key_type key_type
std::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
property_traits< PMap >::reference reference
read_write_property_map_tag category
boost::graph_traits< vtkGraph * >::edges_size_type num_edges(vtkGraph *g)
vtkGraphIndexMap const_type
boost::graph_traits< vtkGraph * >::vertices_size_type num_vertices(vtkGraph *g)
vtkIdType vertices_size_type
vtkEdgeType edge_descriptor
vtk_edge_iterator(vtkGraph *g=nullptr, vtkIdType v=0)
A type representing the union of many types.
dynamic, self-adjusting array of double
void remove_edge(graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *g)
Base class for graph data types.
readable_property_map_tag category
dynamic, self-adjusting array of int
static vtkInformationIntegerKey * DATA_PIECE_NUMBER()
adjacency_iterator_generator< vtkGraph *, vertex_descriptor, out_edge_iterator >::type adjacency_iterator
vtkEdgeType AddEdge(vtkIdType u, vtkIdType v)
Adds an undirected edge from u to v, where u and v are vertex indices, and returns a vtkEdgeType stru...
virtual vtkIdType GetDegree(vtkIdType v)
The total of all incoming and outgoing vertices for vertex v.
undirected_tag directed_category
static vertex_descriptor null_vertex()
vtkIdType vertex_descriptor
allow_parallel_edge_tag edge_parallel_category
static edge_descriptor null_edge()
property_traits< PMap >::category category
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
friend class iterator_core_access
friend class iterator_core_access
abstract superclass for arrays of numeric data
void put(vtkDataArray *arr, vtkIdType key, const double &value)
std::pair< boost::graph_traits< vtkGraph * >::adjacency_iterator, boost::graph_traits< vtkGraph * >::adjacency_iterator > adjacent_vertices(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
An editable directed graph.
bool has_no_edges(vtkGraph *g)
boost::graph_traits< vtkMutableDirectedGraph * >::vertex_descriptor add_vertex(vtkMutableDirectedGraph *g)
virtual void InsertVariantValue(vtkIdType valueIdx, vtkVariant value)=0
Insert a value into the array from a variant.
void SetTuple1(vtkIdType tupleIdx, double value)
These methods are included as convenience for the wrappers.
An editable undirected graph.
reference operator[](const key_type &key) const
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
virtual vtkIdType GetInDegree(vtkIdType v)
The number of incoming edges to vertex v.
vtkGraphIndexMap const_type
property_traits< PMap >::value_type value_type
static vtkMutableDirectedGraph * SafeDownCast(vtkObjectBase *o)
vtk_in_edge_pointer_iterator(vtkGraph *g=nullptr, vtkIdType v=0, bool end=false)
vtkDistributedGraphHelper * GetDistributedGraphHelper()
Retrieves the distributed graph helper for this graph.
vtk_vertex_iterator(vtkIdType i=0)
readable_property_map_tag category
std::pair< boost::graph_traits< vtkMutableDirectedGraph * >::edge_descriptor, bool > add_edge(boost::graph_traits< vtkMutableDirectedGraph * >::vertex_descriptor u, boost::graph_traits< vtkMutableDirectedGraph * >::vertex_descriptor v, vtkMutableDirectedGraph *g)
vtk_vertex_iterator vertex_iterator
reference operator[](const key_type &key) const
property_traits< PMap >::value_type value_type
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
A rooted tree data structure.
friend class iterator_core_access
virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it)
Initializes the out edge iterator to iterate over all outgoing edges of vertex v. ...
property_traits< PMap >::value_type value_type
void RemoveEdge(vtkIdType e)
Removes the edge from the graph.
void RemoveEdge(vtkIdType e)
Removes the edge from the graph.
vtkIdType MakeDistributedId(int owner, vtkIdType local)
Builds a distributed ID consisting of the given owner and the local ID.
static vtkMutableUndirectedGraph * SafeDownCast(vtkObjectBase *o)
boost::graph_traits< vtkGraph * >::degree_size_type out_degree(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
boost::graph_traits< vtkGraph * >::degree_size_type degree(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
boost::graph_traits< vtkDirectedGraph * >::degree_size_type in_degree(boost::graph_traits< vtkDirectedGraph * >::vertex_descriptor u, vtkDirectedGraph *g)
vtk_out_edge_pointer_iterator(vtkGraph *g=nullptr, vtkIdType v=0, bool end=false)
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
virtual vtkIdType GetOutDegree(vtkIdType v)
The number of outgoing edges from vertex v.
vtkGraphIndexMap get(edge_index_t, vtkGraph *)
vtkPropertyMapMacro(vtkIntArray, int)