30 #ifndef vtkBoostGraphAdapter_h 31 #define vtkBoostGraphAdapter_h 49 #include <boost/version.hpp> 61 struct read_write_property_map_tag;
63 #define vtkPropertyMapMacro(T, V) \ 65 struct property_traits<T*> \ 67 typedef V value_type; \ 68 typedef V reference; \ 69 typedef vtkIdType key_type; \ 70 typedef read_write_property_map_tag category; \ 73 inline property_traits<T*>::reference get(T* const& arr, property_traits<T*>::key_type key) \ 75 return arr->GetValue(key); \ 79 T* arr, property_traits<T*>::key_type key, const property_traits<T*>::value_type& value) \ 81 arr->InsertValue(key, value); \ 101 return arr->GetTuple1(
key);
121 return arr->GetVariantValue(
key);
128 #if defined(_MSC_VER) 139 #include <boost/config.hpp> 140 #include <boost/graph/adjacency_iterator.hpp> 141 #include <boost/graph/graph_traits.hpp> 142 #include <boost/graph/properties.hpp> 143 #include <boost/iterator/iterator_facade.hpp> 153 :
public iterator_facade<vtk_vertex_iterator, vtkIdType, bidirectional_traversal_tag,
154 const vtkIdType&, vtkIdType>
167 void increment() {
index++; }
168 void decrement() {
index--; }
172 friend class iterator_core_access;
176 :
public iterator_facade<vtk_edge_iterator, vtkEdgeType, forward_traversal_tag,
177 const vtkEdgeType&, vtkIdType>
190 lastVertex = graph->GetNumberOfVertices();
205 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
210 if (vertex < lastVertex)
215 graph->GetOutEdges(vertex, iter, nedges);
225 || (((helper && myRank == helper->
GetVertexOwner(iter->Target)) || !helper) &&
226 vertex > iter->Target))
251 return vertex == other.vertex && iter == other.iter;
261 this->graph ? this->graph->GetDistributedGraphHelper() : 0;
271 || (((helper && myRank == helper->
GetVertexOwner(iter->Target)) || !helper) &&
272 vertex > iter->Target)))
287 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
292 if (vertex < lastVertex)
295 graph->GetOutEdges(vertex, iter, nedges);
305 void RecalculateEdge()
309 edge =
vtkEdgeType(vertex, iter->Target, iter->Id);
321 friend class iterator_core_access;
325 :
public iterator_facade<vtk_out_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
326 const vtkEdgeType&, ptrdiff_t>
336 g->GetOutEdges(vertex, iter, nedges);
366 void RecalculateEdge()
370 edge =
vtkEdgeType(vertex, iter->Target, iter->Id);
378 friend class iterator_core_access;
382 :
public iterator_facade<vtk_in_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
383 const vtkEdgeType&, ptrdiff_t>
393 g->GetInEdges(vertex, iter, nedges);
423 void RecalculateEdge()
427 edge =
vtkEdgeType(iter->Source, vertex, iter->Id);
435 friend class iterator_core_access;
445 :
public virtual bidirectional_graph_tag
446 ,
public virtual edge_list_graph_tag
447 ,
public virtual vertex_list_graph_tag
448 ,
public virtual adjacency_graph_tag
475 #if BOOST_VERSION >= 104500 477 struct graph_property_type<
vtkGraph*>
479 typedef no_property
type;
495 #if BOOST_VERSION >= 104500 499 typedef no_property
type;
553 #if BOOST_VERSION >= 104500 556 struct graph_property_type<vtkDirectedGraph*> : graph_property_type<vtkGraph*>
562 struct graph_property_type<vtkDirectedGraph*
const> : graph_property_type<vtkGraph*>
591 #if BOOST_VERSION >= 104500 594 struct graph_bundle_type<vtkDirectedGraph*> : graph_bundle_type<vtkGraph*>
600 struct graph_bundle_type<vtkDirectedGraph*
const> : graph_bundle_type<vtkGraph*>
669 #if BOOST_VERSION >= 104500 672 struct graph_property_type<vtkUndirectedGraph*> : graph_property_type<vtkGraph*>
678 struct graph_property_type<vtkUndirectedGraph*
const> : graph_property_type<vtkGraph*>
707 #if BOOST_VERSION >= 104500 710 struct graph_bundle_type<vtkUndirectedGraph*> : graph_bundle_type<vtkGraph*>
716 struct graph_bundle_type<vtkUndirectedGraph*
const> : graph_bundle_type<vtkGraph*>
765 #if BOOST_VERSION >= 104500 768 struct graph_property_type<vtkMutableDirectedGraph*> : graph_property_type<vtkDirectedGraph*>
774 struct graph_property_type<vtkMutableDirectedGraph*
const> : graph_property_type<vtkDirectedGraph*>
787 struct vertex_property_type<vtkMutableDirectedGraph*
const>
804 #if BOOST_VERSION >= 104500 807 struct graph_bundle_type<vtkMutableDirectedGraph*> : graph_bundle_type<vtkDirectedGraph*>
813 struct graph_bundle_type<vtkMutableDirectedGraph*
const> : graph_bundle_type<vtkDirectedGraph*>
862 #if BOOST_VERSION >= 104500 865 struct graph_property_type<vtkMutableUndirectedGraph*> : graph_property_type<vtkUndirectedGraph*>
871 struct graph_property_type<vtkMutableUndirectedGraph*
const>
872 : graph_property_type<vtkUndirectedGraph*>
885 struct vertex_property_type<vtkMutableUndirectedGraph*
const>
898 struct edge_property_type<vtkMutableUndirectedGraph*
const>
903 #if BOOST_VERSION >= 104500 906 struct graph_bundle_type<vtkMutableUndirectedGraph*> : graph_bundle_type<vtkUndirectedGraph*>
912 struct graph_bundle_type<vtkMutableUndirectedGraph*
const> : graph_bundle_type<vtkUndirectedGraph*>
925 struct vertex_bundle_type<vtkMutableUndirectedGraph*
const>
959 inline boost::graph_traits<vtkGraph*>::vertex_descriptor
source(
960 boost::graph_traits<vtkGraph*>::edge_descriptor e,
vtkGraph*)
965 inline boost::graph_traits<vtkGraph*>::vertex_descriptor
target(
966 boost::graph_traits<vtkGraph*>::edge_descriptor e,
vtkGraph*)
971 inline std::pair<boost::graph_traits<vtkGraph*>::vertex_iterator,
972 boost::graph_traits<vtkGraph*>::vertex_iterator>
975 typedef boost::graph_traits<vtkGraph*>::vertex_iterator Iter;
980 start = helper->MakeDistributedId(rank, start);
986 inline std::pair<boost::graph_traits<vtkGraph*>::edge_iterator,
987 boost::graph_traits<vtkGraph*>::edge_iterator>
990 typedef boost::graph_traits<vtkGraph*>::edge_iterator Iter;
994 inline std::pair<boost::graph_traits<vtkGraph*>::out_edge_iterator,
995 boost::graph_traits<vtkGraph*>::out_edge_iterator>
998 typedef boost::graph_traits<vtkGraph*>::out_edge_iterator Iter;
999 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u,
true));
1003 inline std::pair<boost::graph_traits<vtkGraph*>::in_edge_iterator,
1004 boost::graph_traits<vtkGraph*>::in_edge_iterator>
1007 typedef boost::graph_traits<vtkGraph*>::in_edge_iterator Iter;
1008 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u,
true));
1012 inline std::pair<boost::graph_traits<vtkGraph*>::adjacency_iterator,
1013 boost::graph_traits<vtkGraph*>::adjacency_iterator>
1016 typedef boost::graph_traits<vtkGraph*>::adjacency_iterator Iter;
1017 typedef boost::graph_traits<vtkGraph*>::out_edge_iterator OutEdgeIter;
1018 std::pair<OutEdgeIter, OutEdgeIter> out =
out_edges(u, g);
1019 return std::make_pair(Iter(out.first, &g), Iter(out.second, &g));
1032 inline boost::graph_traits<vtkGraph*>::degree_size_type
out_degree(
1033 boost::graph_traits<vtkGraph*>::vertex_descriptor u,
vtkGraph* g)
1038 inline boost::graph_traits<vtkDirectedGraph*>::degree_size_type
in_degree(
1039 boost::graph_traits<vtkDirectedGraph*>::vertex_descriptor u,
vtkDirectedGraph* g)
1044 inline boost::graph_traits<vtkGraph*>::degree_size_type
degree(
1045 boost::graph_traits<vtkGraph*>::vertex_descriptor u,
vtkGraph* g)
1050 inline boost::graph_traits<vtkMutableDirectedGraph*>::vertex_descriptor
add_vertex(
1056 inline std::pair<boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor,
bool>
add_edge(
1057 boost::graph_traits<vtkMutableDirectedGraph*>::vertex_descriptor u,
1060 boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor e = g->
AddEdge(u, v);
1061 return std::make_pair(e,
true);
1064 inline boost::graph_traits<vtkMutableUndirectedGraph*>::vertex_descriptor
add_vertex(
1070 inline std::pair<boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor,
bool>
add_edge(
1071 boost::graph_traits<vtkMutableUndirectedGraph*>::vertex_descriptor u,
1072 boost::graph_traits<vtkMutableUndirectedGraph*>::vertex_descriptor v,
1075 boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor e = g->
AddEdge(u, v);
1076 return std::make_pair(e,
true);
1108 template <
typename PMap>
1125 template <
typename PMap>
1129 return get(helper.pmap,
key.Id);
1132 template <
typename PMap>
1143 template <
typename PMap>
1160 template <
typename PMap>
1164 return get(helper.pmap,
key);
1167 template <
typename PMap>
1200 template <
typename PMap>
1217 template <
typename PMap>
1221 return multi.multiplier *
get(multi.pmap,
key);
1224 template <
typename PMap>
1304 #if BOOST_VERSION > 104000 1305 #include <boost/property_map/vector_property_map.hpp> 1307 #include <boost/vector_property_map.hpp> 1310 #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.
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)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
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)
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
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)
property_traits< PMap >::category category
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
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)
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)
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)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
vtkIdType vertices_size_type
vtkEdgeType edge_descriptor
A atomic type representing the union of many types.
dynamic, self-adjusting array of double
Base class for graph data types.
readable_property_map_tag category
dynamic, self-adjusting array of int
boost::graph_traits< vtkDirectedGraph * >::degree_size_type in_degree(boost::graph_traits< vtkDirectedGraph *>::vertex_descriptor u, vtkDirectedGraph *g)
static vtkInformationIntegerKey * DATA_PIECE_NUMBER()
adjacency_iterator_generator< vtkGraph *, vertex_descriptor, out_edge_iterator >::type adjacency_iterator
reference operator[](const key_type &key) const
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 * >::degree_size_type out_degree(boost::graph_traits< vtkGraph *>::vertex_descriptor u, vtkGraph *g)
abstract superclass for arrays of numeric data
void put(vtkDataArray *arr, vtkIdType key, const double &value)
reference operator[](const key_type &key) const
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.
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)
vtkDistributedGraphHelper * GetDistributedGraphHelper()
Retrieves the distributed graph helper for this graph.
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
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.
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)
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)
void remove_edge(graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *g)
boost::graph_traits< vtkGraph * >::degree_size_type degree(boost::graph_traits< vtkGraph *>::vertex_descriptor u, vtkGraph *g)
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)