30 #ifndef vtkBoostGraphAdapter_h 31 #define vtkBoostGraphAdapter_h 49 #include <boost/version.hpp> 59 struct read_write_property_map_tag;
61 #define vtkPropertyMapMacro(T, V) \ 63 struct property_traits<T*> \ 65 typedef V value_type; \ 66 typedef V reference; \ 67 typedef vtkIdType key_type; \ 68 typedef read_write_property_map_tag category; \ 71 inline property_traits<T*>::reference \ 74 property_traits<T*>::key_type key) \ 76 return arr->GetValue(key); \ 82 property_traits<T*>::key_type key, \ 83 const property_traits<T*>::value_type & value) \ 85 arr->InsertValue(key, value); \ 136 #if defined(_MSC_VER) 146 #include <boost/config.hpp> 147 #include <boost/iterator/iterator_facade.hpp> 148 #include <boost/graph/graph_traits.hpp> 149 #include <boost/graph/properties.hpp> 150 #include <boost/graph/adjacency_iterator.hpp> 159 public iterator_facade<vtk_vertex_iterator,
161 bidirectional_traversal_tag,
172 {
return index == other.index; }
174 void increment() {
index++; }
175 void decrement() {
index--; }
179 friend class iterator_core_access;
183 public iterator_facade<vtk_edge_iterator,
185 forward_traversal_tag,
191 directed(false), vertex(v), lastVertex(v), iter(0), end(0), graph(g)
195 lastVertex = graph->GetNumberOfVertices();
200 = this->graph? this->graph->GetDistributedGraphHelper() : 0;
211 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
216 if (vertex < lastVertex)
221 graph->GetOutEdges(vertex, iter, nedges);
233 && vertex > iter->Target)))
248 {
return vtkEdgeType(vertex, iter->Target, iter->Id); }
251 {
return vertex == other.vertex && iter == other.iter; }
260 = this->graph? this->graph->GetDistributedGraphHelper() : 0;
273 && vertex > iter->Target)))
287 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
292 if (vertex < lastVertex)
295 graph->GetOutEdges(vertex, iter, nedges);
312 friend class iterator_core_access;
316 public iterator_facade<vtk_out_edge_pointer_iterator,
318 bidirectional_traversal_tag,
329 g->GetOutEdges(vertex, iter, nedges);
341 {
return iter == other.iter; }
343 void increment() { iter++; }
344 void decrement() { iter--; }
349 friend class iterator_core_access;
353 public iterator_facade<vtk_in_edge_pointer_iterator,
355 bidirectional_traversal_tag,
366 g->GetInEdges(vertex, iter, nedges);
378 {
return iter == other.iter; }
380 void increment() { iter++; }
381 void decrement() { iter--; }
386 friend class iterator_core_access;
396 public virtual bidirectional_graph_tag,
397 public virtual edge_list_graph_tag,
398 public virtual vertex_list_graph_tag,
399 public virtual adjacency_graph_tag { };
419 typedef adjacency_iterator_generator<
vtkGraph*,
423 #if BOOST_VERSION >= 104500 425 struct graph_property_type<
vtkGraph* > {
426 typedef no_property
type;
440 #if BOOST_VERSION >= 104500 442 struct graph_bundle_type<
vtkGraph* > {
443 typedef no_property
type;
462 inline void remove_edge(graph_traits<vtkGraph*>::edge_descriptor e,
492 #if BOOST_VERSION >= 104500 495 struct graph_property_type< vtkDirectedGraph* >
496 : graph_property_type< vtkGraph* > { };
500 struct graph_property_type< vtkDirectedGraph*
const >
501 : graph_property_type< vtkGraph* > { };
506 struct vertex_property_type< vtkDirectedGraph* >
511 struct vertex_property_type< vtkDirectedGraph*
const >
516 struct edge_property_type< vtkDirectedGraph* >
521 struct edge_property_type< vtkDirectedGraph*
const >
524 #if BOOST_VERSION >= 104500 527 struct graph_bundle_type< vtkDirectedGraph* >
528 : graph_bundle_type< vtkGraph* > { };
532 struct graph_bundle_type< vtkDirectedGraph*
const >
533 : graph_bundle_type< vtkGraph* > { };
538 struct vertex_bundle_type< vtkDirectedGraph* >
543 struct vertex_bundle_type< vtkDirectedGraph*
const >
548 struct edge_bundle_type< vtkDirectedGraph* >
553 struct edge_bundle_type< vtkDirectedGraph*
const >
586 #if BOOST_VERSION >= 104500 589 struct graph_property_type< vtkUndirectedGraph* >
590 : graph_property_type< vtkGraph* > { };
594 struct graph_property_type< vtkUndirectedGraph*
const >
595 : graph_property_type< vtkGraph* > { };
600 struct vertex_property_type< vtkUndirectedGraph* >
605 struct vertex_property_type< vtkUndirectedGraph*
const >
610 struct edge_property_type< vtkUndirectedGraph* >
615 struct edge_property_type< vtkUndirectedGraph*
const >
618 #if BOOST_VERSION >= 104500 621 struct graph_bundle_type< vtkUndirectedGraph* >
622 : graph_bundle_type< vtkGraph* > { };
626 struct graph_bundle_type< vtkUndirectedGraph*
const >
627 : graph_bundle_type< vtkGraph* > { };
632 struct vertex_bundle_type< vtkUndirectedGraph* >
637 struct vertex_bundle_type< vtkUndirectedGraph*
const >
642 struct edge_bundle_type< vtkUndirectedGraph* >
647 struct edge_bundle_type< vtkUndirectedGraph*
const >
664 #if BOOST_VERSION >= 104500 667 struct graph_property_type< vtkMutableDirectedGraph* >
668 : graph_property_type< vtkDirectedGraph* > { };
672 struct graph_property_type< vtkMutableDirectedGraph*
const >
673 : graph_property_type< vtkDirectedGraph* > { };
678 struct vertex_property_type< vtkMutableDirectedGraph* >
683 struct vertex_property_type< vtkMutableDirectedGraph*
const >
688 struct edge_property_type< vtkMutableDirectedGraph* >
693 struct edge_property_type< vtkMutableDirectedGraph*
const >
696 #if BOOST_VERSION >= 104500 699 struct graph_bundle_type< vtkMutableDirectedGraph* >
700 : graph_bundle_type< vtkDirectedGraph* > { };
704 struct graph_bundle_type< vtkMutableDirectedGraph*
const >
705 : graph_bundle_type< vtkDirectedGraph* > { };
710 struct vertex_bundle_type< vtkMutableDirectedGraph* >
715 struct vertex_bundle_type< vtkMutableDirectedGraph*
const >
720 struct edge_bundle_type< vtkMutableDirectedGraph* >
725 struct edge_bundle_type< vtkMutableDirectedGraph*
const >
742 #if BOOST_VERSION >= 104500 745 struct graph_property_type< vtkMutableUndirectedGraph* >
746 : graph_property_type< vtkUndirectedGraph* > { };
750 struct graph_property_type< vtkMutableUndirectedGraph*
const >
751 : graph_property_type< vtkUndirectedGraph* > { };
756 struct vertex_property_type< vtkMutableUndirectedGraph* >
761 struct vertex_property_type< vtkMutableUndirectedGraph*
const >
766 struct edge_property_type< vtkMutableUndirectedGraph* >
771 struct edge_property_type< vtkMutableUndirectedGraph*
const >
774 #if BOOST_VERSION >= 104500 777 struct graph_bundle_type< vtkMutableUndirectedGraph* >
778 : graph_bundle_type< vtkUndirectedGraph* > { };
782 struct graph_bundle_type< vtkMutableUndirectedGraph*
const >
783 : graph_bundle_type< vtkUndirectedGraph* > { };
788 struct vertex_bundle_type< vtkMutableUndirectedGraph* >
793 struct vertex_bundle_type< vtkMutableUndirectedGraph*
const >
798 struct edge_bundle_type< vtkMutableUndirectedGraph* >
803 struct edge_bundle_type< vtkMutableUndirectedGraph*
const >
846 start = helper->MakeDistributedId(rank, start);
849 return std::make_pair( Iter(start),
870 std::pair<Iter, Iter> p = std::make_pair( Iter(g, u), Iter(g, u,
true) );
882 std::pair<Iter, Iter> p = std::make_pair( Iter(g, u), Iter(g, u,
true) );
895 std::pair<OutEdgeIter, OutEdgeIter> out =
out_edges(u, g);
896 return std::make_pair( Iter(out.first, &g), Iter(out.second, &g) );
919 inline boost::graph_traits< vtkDirectedGraph* >::degree_size_type
921 boost::graph_traits< vtkDirectedGraph* >::vertex_descriptor u,
935 inline boost::graph_traits< vtkMutableDirectedGraph* >::vertex_descriptor
942 boost::graph_traits< vtkMutableDirectedGraph* >::edge_descriptor,
945 boost::graph_traits< vtkMutableDirectedGraph* >::vertex_descriptor u,
946 boost::graph_traits< vtkMutableDirectedGraph* >::vertex_descriptor v,
949 boost::graph_traits< vtkMutableDirectedGraph* >::edge_descriptor e = g->
AddEdge(u, v);
950 return std::make_pair(e,
true);
953 inline boost::graph_traits< vtkMutableUndirectedGraph* >::vertex_descriptor
960 boost::graph_traits< vtkMutableUndirectedGraph* >::edge_descriptor,
963 boost::graph_traits< vtkMutableUndirectedGraph* >::vertex_descriptor u,
964 boost::graph_traits< vtkMutableUndirectedGraph* >::vertex_descriptor v,
967 boost::graph_traits< vtkMutableUndirectedGraph* >::edge_descriptor e = g->
AddEdge(u, v);
968 return std::make_pair(e,
true);
999 template<
typename PMap>
1011 template<
typename PMap>
1017 return get(helper.
pmap,
key.Id);
1020 template<
typename PMap>
1056 template<
typename PMap>
1069 template<
typename PMap>
1078 template<
typename PMap>
1142 #if BOOST_VERSION > 104000 1143 #include <boost/property_map/vector_property_map.hpp> 1145 #include <boost/vector_property_map.hpp> 1149 #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
vtk_out_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
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)
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
Forward declaration required for Boost serialization.
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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
vtkPropertyMapMacro(vtkIntArray, int) vtkPropertyMapMacro(vtkIdTypeArray
vtkIdType GetEdgeOwner(vtkIdType e_id) const
Returns owner of edge with ID e_id, by extracting top ceil(log2 P) bits of e_id.
Abstract superclass for all arrays.
vtkGraphPropertyMapMultiplier(PMap m, float multi=1)
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
vtk_edge_iterator edge_iterator
dynamic, self-adjusting array of vtkIdType
property_traits< PMap >::key_type key_type
virtual vtkVariant GetVariantValue(vtkIdType valueIdx)
Retrieve value from the array as a variant.
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
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
abstract superclass for arrays of numeric data
std::pair< boost::graph_traits< vtkGraph *>::vertex_iterator, boost::graph_traits< vtkGraph *>::vertex_iterator > vertices(vtkGraph *g)
void put(vtkDataArray *arr, vtkIdType key, const double &value)
An editable directed graph.
bool has_no_edges(vtkGraph *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.
virtual vtkIdType GetInDegree(vtkIdType v)
The number of incoming edges to vertex 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()
Retrieves the distributed graph helper for this graph.
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkIdType GetVertexOwner(vtkIdType v) const
Returns owner of vertex v, by extracting top ceil(log2 P) bits of v.
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)
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
A rooted tree data structure.
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)
property_traits< PMap >::value_type value_type
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)
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)
void RemoveEdge(vtkIdType e)
Removes the edge from the graph.
boost::graph_traits< vtkGraph *>::degree_size_type out_degree(boost::graph_traits< vtkGraph * >::vertex_descriptor u, vtkGraph *g)
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)
void remove_edge(graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *g)
std::pair< boost::graph_traits< vtkGraph *>::edge_iterator, boost::graph_traits< vtkGraph *>::edge_iterator > edges(vtkGraph *g)
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)
virtual vtkIdType GetOutDegree(vtkIdType v)
The number of outgoing edges from vertex v.
vtkGraphIndexMap get(edge_index_t, vtkGraph *)