29 #ifndef __vtkBoostGraphAdapter_h
30 #define __vtkBoostGraphAdapter_h
32 #include "vtkAbstractArray.h"
34 #include "vtkDistributedGraphHelper.h"
36 #include "vtkDataArray.h"
37 #include "vtkDoubleArray.h"
38 #include "vtkFloatArray.h"
39 #include "vtkIdTypeArray.h"
40 #include "vtkInformation.h"
41 #include "vtkIntArray.h"
46 #include "vtkVariant.h"
48 #include <boost/version.hpp>
58 struct read_write_property_map_tag;
60 #define vtkPropertyMapMacro(T, V) \
62 struct property_traits<T*> \
64 typedef V value_type; \
65 typedef V reference; \
66 typedef vtkIdType key_type; \
67 typedef read_write_property_map_tag category; \
70 inline property_traits<T*>::reference \
73 property_traits<T*>::key_type key) \
75 return arr->GetValue(key); \
81 property_traits<T*>::key_type key, \
82 const property_traits<T*>::value_type & value) \
84 arr->InsertValue(key, value); \
103 get(vtkDataArray *
const& arr, vtkIdType key)
105 return arr->GetTuple1(key);
109 put(vtkDataArray *arr, vtkIdType key,
const double& value)
111 arr->SetTuple1(key, value);
125 get(vtkAbstractArray *
const& arr, vtkIdType key)
127 return arr->GetVariantValue(key);
131 put(vtkAbstractArray *arr, vtkIdType key,
const vtkVariant& value)
133 arr->InsertVariantValue(key, value);
137 #include <vtksys/stl/utility>
139 #include <boost/config.hpp>
140 #include <boost/iterator/iterator_facade.hpp>
141 #include <boost/graph/graph_traits.hpp>
142 #include <boost/graph/properties.hpp>
143 #include <boost/graph/adjacency_iterator.hpp>
152 public iterator_facade<vtk_vertex_iterator,
154 bidirectional_traversal_tag,
162 vtkIdType dereference()
const {
return index; }
165 {
return index == other.index; }
167 void increment() { index++; }
168 void decrement() { index--; }
176 public iterator_facade<vtk_edge_iterator,
178 forward_traversal_tag,
184 directed(false), vertex(v), lastVertex(v), iter(0), end(0), graph(g)
191 vtkIdType myRank = -1;
192 vtkDistributedGraphHelper *helper
197 vertex = helper->MakeDistributedId(myRank, vertex);
198 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
204 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
209 if (vertex < lastVertex)
221 (helper && helper->GetEdgeOwner(iter->
Id) != myRank)
224 && myRank == helper->GetVertexOwner(iter->
Target))
226 && vertex > iter->
Target)))
244 {
return vertex == other.vertex && iter == other.iter; }
251 vtkIdType myRank = -1;
252 vtkDistributedGraphHelper *helper
261 (helper && helper->GetEdgeOwner(iter->
Id) != myRank)
264 && myRank == helper->GetVertexOwner(iter->
Target))
266 && vertex > iter->
Target)))
280 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
285 if (vertex < lastVertex)
300 vtkIdType lastVertex;
309 public iterator_facade<vtk_out_edge_pointer_iterator,
311 bidirectional_traversal_tag,
322 g->GetOutEdges(vertex, iter, nedges);
334 {
return iter == other.iter; }
336 void increment() { iter++; }
337 void decrement() { iter--; }
346 public iterator_facade<vtk_in_edge_pointer_iterator,
348 bidirectional_traversal_tag,
359 g->GetInEdges(vertex, iter, nedges);
371 {
return iter == other.iter; }
373 void increment() { iter++; }
374 void decrement() { iter--; }
389 public virtual bidirectional_graph_tag,
390 public virtual edge_list_graph_tag,
391 public virtual vertex_list_graph_tag,
392 public virtual adjacency_graph_tag { };
412 typedef adjacency_iterator_generator<
vtkGraph*,
416 #if BOOST_VERSION >= 104500
418 struct graph_property_type<
vtkGraph* > {
419 typedef no_property type;
433 #if BOOST_VERSION >= 104500
435 struct graph_bundle_type<
vtkGraph* > {
436 typedef no_property type;
485 #if BOOST_VERSION >= 104500
489 : graph_property_type< vtkGraph* > { };
494 : graph_property_type< vtkGraph* > { };
517 #if BOOST_VERSION >= 104500
521 : graph_bundle_type< vtkGraph* > { };
526 : graph_bundle_type< vtkGraph* > { };
579 #if BOOST_VERSION >= 104500
583 : graph_property_type< vtkGraph* > { };
588 : graph_property_type< vtkGraph* > { };
611 #if BOOST_VERSION >= 104500
615 : graph_bundle_type< vtkGraph* > { };
620 : graph_bundle_type< vtkGraph* > { };
657 #if BOOST_VERSION >= 104500
661 : graph_property_type< vtkDirectedGraph* > { };
666 : graph_property_type< vtkDirectedGraph* > { };
689 #if BOOST_VERSION >= 104500
693 : graph_bundle_type< vtkDirectedGraph* > { };
698 : graph_bundle_type< vtkDirectedGraph* > { };
735 #if BOOST_VERSION >= 104500
739 : graph_property_type< vtkUndirectedGraph* > { };
744 : graph_property_type< vtkUndirectedGraph* > { };
767 #if BOOST_VERSION >= 104500
771 : graph_bundle_type< vtkUndirectedGraph* > { };
776 : graph_bundle_type< vtkUndirectedGraph* > { };
828 inline vtksys_stl::pair<
830 boost::graph_traits< vtkGraph* >::vertex_iterator >
833 typedef boost::graph_traits< vtkGraph* >::vertex_iterator Iter;
839 start = helper->MakeDistributedId(rank, start);
842 return vtksys_stl::make_pair( Iter(start),
846 inline vtksys_stl::pair<
848 boost::graph_traits< vtkGraph* >::edge_iterator >
851 typedef boost::graph_traits< vtkGraph* >::edge_iterator Iter;
855 inline vtksys_stl::pair<
857 boost::graph_traits< vtkGraph* >::out_edge_iterator >
862 typedef boost::graph_traits< vtkGraph* >::out_edge_iterator Iter;
863 vtksys_stl::pair<Iter, Iter> p = vtksys_stl::make_pair( Iter(g, u), Iter(g, u,
true) );
867 inline vtksys_stl::pair<
869 boost::graph_traits< vtkGraph* >::in_edge_iterator >
874 typedef boost::graph_traits< vtkGraph* >::in_edge_iterator Iter;
875 vtksys_stl::pair<Iter, Iter> p = vtksys_stl::make_pair( Iter(g, u), Iter(g, u,
true) );
879 inline vtksys_stl::pair<
881 boost::graph_traits< vtkGraph* >::adjacency_iterator >
886 typedef boost::graph_traits< vtkGraph* >::adjacency_iterator Iter;
887 typedef boost::graph_traits< vtkGraph* >::out_edge_iterator OutEdgeIter;
888 vtksys_stl::pair<OutEdgeIter, OutEdgeIter> out =
out_edges(u, g);
889 return vtksys_stl::make_pair( Iter(out.first, &g), Iter(out.second, &g) );
934 inline vtksys_stl::pair<
942 boost::graph_traits< vtkMutableDirectedGraph* >::edge_descriptor e = g->
AddEdge(u, v);
943 return vtksys_stl::make_pair(e,
true);
952 inline vtksys_stl::pair<
960 boost::graph_traits< vtkMutableUndirectedGraph* >::edge_descriptor e = g->
AddEdge(u, v);
961 return vtksys_stl::make_pair(e,
true);
992 template<
typename PMap>
1004 template<
typename PMap>
1010 return get(helper.pmap, key.Id);
1013 template<
typename PMap>
1049 template<
typename PMap>
1062 template<
typename PMap>
1068 return multi.multiplier *
get(multi.pmap, key);
1071 template<
typename PMap>
1135 #if BOOST_VERSION > 104000
1136 #include <boost/property_map/vector_property_map.hpp>
1138 #include <boost/vector_property_map.hpp>
1142 #endif // __vtkBoostGraphAdapter_h
static vtkDirectedGraph * SafeDownCast(vtkObjectBase *o)
virtual vtkIdType GetNumberOfEdges()
property_traits< PMap >::reference reference
property_traits< PMap >::category category
vtk_out_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
vtkEdgeType AddEdge(vtkIdType u, vtkIdType v)
vtkGraphEdgePropertyMapHelper(PMap m)
virtual vtkInformation * GetInformation()
read_write_property_map_tag category
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
virtual vtkIdType GetNumberOfVertices()
vtksys_stl::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
vtk_out_edge_pointer_iterator out_edge_iterator
vtksys_stl::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
property_traits< PMap >::reference reference
vtkIdType degree_size_type
vtkPropertyMapMacro(vtkIntArray, int) vtkPropertyMapMacro(vtkIdTypeArray
vtkGraphPropertyMapMultiplier(PMap m, float multi=1)
friend class iterator_core_access
vtkGraph_traversal_category traversal_category
directed_tag directed_category
vtksys_stl::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_in_edge_pointer_iterator in_edge_iterator
vtkIdType edges_size_type
vtk_edge_iterator edge_iterator
vtksys_stl::pair< boost::graph_traits< vtkGraph * >::adjacency_iterator, boost::graph_traits< vtkGraph * >::adjacency_iterator > adjacent_vertices(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
property_traits< PMap >::key_type key_type
read_write_property_map_tag category
vtkGraphIndexMap const_type
boost::graph_traits< vtkGraph * >::edges_size_type num_edges(vtkGraph *g)
vtkIdType vertices_size_type
boost::graph_traits< vtkMutableDirectedGraph * >::vertex_descriptor add_vertex(vtkMutableDirectedGraph *g)
vtkEdgeType edge_descriptor
boost::graph_traits< vtkDirectedGraph * >::degree_size_type in_degree(boost::graph_traits< vtkDirectedGraph * >::vertex_descriptor u, vtkDirectedGraph *g)
void remove_edge(graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *g)
Base class for graph data types.
readable_property_map_tag category
static vtkInformationIntegerKey * DATA_PIECE_NUMBER()
adjacency_iterator_generator< vtkGraph *, vertex_descriptor, out_edge_iterator >::type adjacency_iterator
vtksys_stl::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)
vtkEdgeType AddEdge(vtkIdType u, vtkIdType v)
virtual vtkIdType GetDegree(vtkIdType 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
friend class iterator_core_access
friend class iterator_core_access
void put(vtkDataArray *arr, vtkIdType key, const double &value)
An editable directed graph.
bool has_no_edges(vtkGraph *g)
An editable undirected graph.
virtual vtkIdType GetInDegree(vtkIdType v)
vtkGraphIndexMap const_type
property_traits< PMap >::value_type value_type
boost::graph_traits< vtkGraph * >::vertices_size_type num_vertices(vtkGraph *g)
static vtkMutableDirectedGraph * SafeDownCast(vtkObjectBase *o)
vtkDistributedGraphHelper * GetDistributedGraphHelper()
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtk_in_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
vtk_vertex_iterator(vtkIdType i=0)
vtk_edge_iterator(vtkGraph *g=0, vtkIdType v=0)
readable_property_map_tag category
vtk_vertex_iterator vertex_iterator
boost::graph_traits< vtkGraph * >::degree_size_type degree(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
vtksys_stl::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)
friend class iterator_core_access
virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it)
property_traits< PMap >::value_type value_type
void RemoveEdge(vtkIdType e)
boost::graph_traits< vtkGraph * >::degree_size_type out_degree(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
void RemoveEdge(vtkIdType e)
static vtkMutableUndirectedGraph * SafeDownCast(vtkObjectBase *o)
virtual vtkIdType GetOutDegree(vtkIdType v)