29 #ifndef __vtkBoostGraphAdapter_h
30 #define __vtkBoostGraphAdapter_h
33 #include "vtkDirectedGraph.h"
35 #include "vtkDataObject.h"
43 #include "vtkMutableUndirectedGraph.h"
45 #include "vtkUndirectedGraph.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); \
105 return arr->GetTuple1(key);
127 return arr->GetVariantValue(key);
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)
196 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
203 directed = (vtkDirectedGraph::SafeDownCast(graph) != 0);
204 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
209 if (vertex < lastVertex)
226 && vertex > iter->
Target)))
244 {
return vertex == other.vertex && iter == other.iter; }
256 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
266 && vertex > iter->
Target)))
280 while (vertex < lastVertex && this->graph->
GetOutDegree(vertex) == 0)
285 if (vertex < 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;
462 else if(vtkMutableUndirectedGraph::SafeDownCast(g))
464 vtkMutableUndirectedGraph::SafeDownCast(g)->RemoveEdge(e.Id);
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
582 struct graph_property_type< vtkUndirectedGraph* >
583 : graph_property_type< vtkGraph* > { };
587 struct graph_property_type< vtkUndirectedGraph*
const >
588 : graph_property_type< vtkGraph* > { };
593 struct vertex_property_type< vtkUndirectedGraph* >
598 struct vertex_property_type< vtkUndirectedGraph*
const >
603 struct edge_property_type< vtkUndirectedGraph* >
608 struct edge_property_type< vtkUndirectedGraph*
const >
611 #if BOOST_VERSION >= 104500
614 struct graph_bundle_type< vtkUndirectedGraph* >
615 : graph_bundle_type< vtkGraph* > { };
619 struct graph_bundle_type< vtkUndirectedGraph*
const >
620 : graph_bundle_type< vtkGraph* > { };
625 struct vertex_bundle_type< vtkUndirectedGraph* >
630 struct vertex_bundle_type< vtkUndirectedGraph*
const >
635 struct edge_bundle_type< vtkUndirectedGraph* >
640 struct edge_bundle_type< vtkUndirectedGraph*
const >
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
738 struct graph_property_type< vtkMutableUndirectedGraph* >
739 : graph_property_type< vtkUndirectedGraph* > { };
743 struct graph_property_type< vtkMutableUndirectedGraph*
const >
744 : graph_property_type< vtkUndirectedGraph* > { };
749 struct vertex_property_type< vtkMutableUndirectedGraph* >
754 struct vertex_property_type< vtkMutableUndirectedGraph*
const >
759 struct edge_property_type< vtkMutableUndirectedGraph* >
764 struct edge_property_type< vtkMutableUndirectedGraph*
const >
767 #if BOOST_VERSION >= 104500
770 struct graph_bundle_type< vtkMutableUndirectedGraph* >
771 : graph_bundle_type< vtkUndirectedGraph* > { };
775 struct graph_bundle_type< vtkMutableUndirectedGraph*
const >
776 : graph_bundle_type< vtkUndirectedGraph* > { };
781 struct vertex_bundle_type< vtkMutableUndirectedGraph* >
786 struct vertex_bundle_type< vtkMutableUndirectedGraph*
const >
791 struct edge_bundle_type< vtkMutableUndirectedGraph* >
796 struct edge_bundle_type< vtkMutableUndirectedGraph*
const >
828 inline vtksys_stl::pair<
830 boost::graph_traits< vtkGraph* >::vertex_iterator >
833 typedef boost::graph_traits< vtkGraph* >::vertex_iterator Iter;
838 g->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
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) );
917 return g->GetInDegree(u);
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);
949 return g->AddVertex();
952 inline vtksys_stl::pair<
958 vtkMutableUndirectedGraph *g)
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>
1095 struct property_map<vtkUndirectedGraph*, vertex_index_t>
1112 struct property_map<vtkUndirectedGraph*, edge_index_t>
1123 struct property_map<vtkUndirectedGraph*
const, vertex_index_t>
1131 struct property_map<vtkUndirectedGraph*
const, edge_index_t>
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
virtual vtkIdType GetNumberOfEdges()
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
vtk_out_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
vtkEdgeType AddEdge(vtkIdType u, vtkIdType v)
vtkGraphEdgePropertyMapHelper(PMap m)
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
Abstract superclass for all arrays.
vtkGraphPropertyMapMultiplier(PMap m, float multi=1)
friend class iterator_core_access
void SetTuple1(vtkIdType i, double value)
vtkIdType GetEdgeOwner(vtkIdType e_id) const
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
dynamic, self-adjusting array of float
vtkIdType GetVertexOwner(vtkIdType v) const
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)
dynamic, self-adjusting array of vtkIdType
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
A atomic type representing the union of many types.
boost::graph_traits< vtkDirectedGraph * >::degree_size_type in_degree(boost::graph_traits< vtkDirectedGraph * >::vertex_descriptor u, vtkDirectedGraph *g)
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
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)
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
abstract superclass for arrays of numeric data
void put(vtkDataArray *arr, vtkIdType key, const double &value)
An editable directed graph.
bool has_no_edges(vtkGraph *g)
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
virtual void InsertVariantValue(vtkIdType idx, vtkVariant value)
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)
A rooted tree data structure.
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)
vtkIdType MakeDistributedId(int owner, vtkIdType local)
virtual vtkIdType GetOutDegree(vtkIdType v)