VTK  9.1.0
vtkBoostGraphAdapter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkBoostGraphAdapter.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15/*-------------------------------------------------------------------------
16 Copyright 2008 Sandia Corporation.
17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18 the U.S. Government retains certain rights in this software.
19-------------------------------------------------------------------------*/
39#ifndef vtkBoostGraphAdapter_h
40#define vtkBoostGraphAdapter_h
41
42#include "vtkAbstractArray.h"
43#include "vtkDataArray.h"
44#include "vtkDataObject.h"
45#include "vtkDirectedGraph.h"
47#include "vtkDoubleArray.h"
48#include "vtkFloatArray.h"
49#include "vtkIdTypeArray.h"
50#include "vtkInformation.h"
51#include "vtkIntArray.h"
54#include "vtkTree.h"
55#include "vtkUndirectedGraph.h"
56#include "vtkVariant.h"
57
58#include <boost/version.hpp>
59
60namespace boost
61{
62//===========================================================================
63// VTK arrays as property maps
64// These need to be defined before including other boost stuff
65
66// Forward declarations are required here, so that we aren't forced
67// to include boost/property_map.hpp.
68template <typename>
70struct read_write_property_map_tag;
71
72#define vtkPropertyMapMacro(T, V) \
73 template <> \
74 struct property_traits<T*> \
75 { \
76 typedef V value_type; \
77 typedef V reference; \
78 typedef vtkIdType key_type; \
79 typedef read_write_property_map_tag category; \
80 }; \
81 \
82 inline property_traits<T*>::reference get(T* const& arr, property_traits<T*>::key_type key) \
83 { \
84 return arr->GetValue(key); \
85 } \
86 \
87 inline void put( \
88 T* arr, property_traits<T*>::key_type key, const property_traits<T*>::value_type& value) \
89 { \
90 arr->InsertValue(key, value); \
91 }
92
97
98// vtkDataArray
99template <>
101{
102 typedef double value_type;
103 typedef double reference;
105 typedef read_write_property_map_tag category;
106};
107
108inline double get(vtkDataArray* const& arr, vtkIdType key)
109{
110 return arr->GetTuple1(key);
111}
112
113inline void put(vtkDataArray* arr, vtkIdType key, const double& value)
114{
115 arr->SetTuple1(key, value);
116}
117
118// vtkAbstractArray as a property map of vtkVariants
119template <>
121{
125 typedef read_write_property_map_tag category;
126};
127
129{
130 return arr->GetVariantValue(key);
131}
132
134{
136}
137#if defined(_MSC_VER)
138namespace detail
139{
142}
143#endif
144}
145
146#include <utility> // STL Header
147
148#include <boost/config.hpp>
149#include <boost/graph/adjacency_iterator.hpp>
150#include <boost/graph/graph_traits.hpp>
151#include <boost/graph/properties.hpp>
152#include <boost/iterator/iterator_facade.hpp>
153
154// The functions and classes in this file allows the user to
155// treat a vtkDirectedGraph or vtkUndirectedGraph object
156// as a boost graph "as is".
157
158namespace boost
159{
160
162 : public iterator_facade<vtk_vertex_iterator, vtkIdType, bidirectional_traversal_tag,
163 const vtkIdType&, vtkIdType>
164{
165public:
167 : index(i)
168 {
169 }
170
171private:
172 const vtkIdType& dereference() const { return index; }
173
174 bool equal(const vtk_vertex_iterator& other) const { return index == other.index; }
175
176 void increment() { index++; }
177 void decrement() { index--; }
178
179 vtkIdType index;
180
182};
183
185 : public iterator_facade<vtk_edge_iterator, vtkEdgeType, forward_traversal_tag,
186 const vtkEdgeType&, vtkIdType>
187{
188public:
189 explicit vtk_edge_iterator(vtkGraph* g = 0, vtkIdType v = 0)
190 : directed(false)
191 , vertex(v)
192 , lastVertex(v)
193 , iter(nullptr)
194 , end(nullptr)
195 , graph(g)
196 {
197 if (graph)
198 {
199 lastVertex = graph->GetNumberOfVertices();
200 }
201
202 vtkIdType myRank = -1;
203 vtkDistributedGraphHelper* helper = this->graph ? this->graph->GetDistributedGraphHelper() : 0;
204 if (helper)
205 {
206 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
207 vertex = helper->MakeDistributedId(myRank, vertex);
208 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
209 }
210
211 if (graph != 0)
212 {
213 directed = (vtkDirectedGraph::SafeDownCast(graph) != 0);
214 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
215 {
216 ++vertex;
217 }
218
219 if (vertex < lastVertex)
220 {
221 // Get the outgoing edges of the first vertex that has outgoing
222 // edges
223 vtkIdType nedges;
224 graph->GetOutEdges(vertex, iter, nedges);
225 if (iter)
226 {
227 end = iter + nedges;
228
229 if (!directed)
230 {
231 while ( // Skip non-local edges
232 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
233 // Skip entirely-local edges where Source > Target
234 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
235 vertex > iter->Target))
236 {
237 this->inc();
238 }
239 }
240 }
241 }
242 else
243 {
244 iter = nullptr;
245 }
246 }
247
248 RecalculateEdge();
249 }
250
251private:
252 const vtkEdgeType& dereference() const
253 {
254 assert(iter);
255 return edge;
256 }
257
258 bool equal(const vtk_edge_iterator& other) const
259 {
260 return vertex == other.vertex && iter == other.iter;
261 }
262
263 void increment()
264 {
265 inc();
266 if (!directed)
267 {
268 vtkIdType myRank = -1;
270 this->graph ? this->graph->GetDistributedGraphHelper() : 0;
271 if (helper)
272 {
273 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
274 }
275
276 while (iter != 0 &&
277 ( // Skip non-local edges
278 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
279 // Skip entirely-local edges where Source > Target
280 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
281 vertex > iter->Target)))
282 {
283 inc();
284 }
285 }
286 RecalculateEdge();
287 }
288
289 void inc()
290 {
291 ++iter;
292 if (iter == end)
293 {
294 // Find a vertex with nonzero out degree.
295 ++vertex;
296 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
297 {
298 ++vertex;
299 }
300
301 if (vertex < lastVertex)
302 {
303 vtkIdType nedges;
304 graph->GetOutEdges(vertex, iter, nedges);
305 end = iter + nedges;
306 }
307 else
308 {
309 iter = nullptr;
310 }
311 }
312 }
313
314 void RecalculateEdge()
315 {
316 if (iter)
317 {
318 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
319 }
320 }
321
322 bool directed;
323 vtkIdType vertex;
324 vtkIdType lastVertex;
325 const vtkOutEdgeType* iter;
326 const vtkOutEdgeType* end;
327 vtkGraph* graph;
328 vtkEdgeType edge;
329
331};
332
334 : public iterator_facade<vtk_out_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
335 const vtkEdgeType&, ptrdiff_t>
336{
337public:
338 explicit vtk_out_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
339 : vertex(v)
340 , iter(nullptr)
341 {
342 if (g)
343 {
344 vtkIdType nedges;
345 g->GetOutEdges(vertex, iter, nedges);
346 if (end)
347 {
348 iter += nedges;
349 }
350 }
351 RecalculateEdge();
352 }
353
354private:
355 const vtkEdgeType& dereference() const
356 {
357 assert(iter);
358 return edge;
359 }
360
361 bool equal(const vtk_out_edge_pointer_iterator& other) const { return iter == other.iter; }
362
363 void increment()
364 {
365 iter++;
366 RecalculateEdge();
367 }
368
369 void decrement()
370 {
371 iter--;
372 RecalculateEdge();
373 }
374
375 void RecalculateEdge()
376 {
377 if (iter)
378 {
379 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
380 }
381 }
382
383 vtkIdType vertex;
384 const vtkOutEdgeType* iter;
385 vtkEdgeType edge;
386
388};
389
391 : public iterator_facade<vtk_in_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
392 const vtkEdgeType&, ptrdiff_t>
393{
394public:
395 explicit vtk_in_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
396 : vertex(v)
397 , iter(nullptr)
398 {
399 if (g)
400 {
401 vtkIdType nedges;
402 g->GetInEdges(vertex, iter, nedges);
403 if (end)
404 {
405 iter += nedges;
406 }
407 }
408 RecalculateEdge();
409 }
410
411private:
412 const vtkEdgeType& dereference() const
413 {
414 assert(iter);
415 return edge;
416 }
417
418 bool equal(const vtk_in_edge_pointer_iterator& other) const { return iter == other.iter; }
419
420 void increment()
421 {
422 iter++;
423 RecalculateEdge();
424 }
425
426 void decrement()
427 {
428 iter--;
429 RecalculateEdge();
430 }
431
432 void RecalculateEdge()
433 {
434 if (iter)
435 {
436 edge = vtkEdgeType(iter->Source, vertex, iter->Id);
437 }
438 }
439
440 vtkIdType vertex;
441 const vtkInEdgeType* iter;
442 vtkEdgeType edge;
443
445};
446
447//===========================================================================
448// vtkGraph
449// VertexAndEdgeListGraphConcept
450// BidirectionalGraphConcept
451// AdjacencyGraphConcept
452
454 : public virtual bidirectional_graph_tag
455 , public virtual edge_list_graph_tag
456 , public virtual vertex_list_graph_tag
457 , public virtual adjacency_graph_tag
458{
459};
460
461template <>
462struct graph_traits<vtkGraph*>
463{
465 static vertex_descriptor null_vertex() { return -1; }
467 static edge_descriptor null_edge() { return vtkEdgeType(-1, -1, -1); }
470
473
474 typedef allow_parallel_edge_tag edge_parallel_category;
479
482};
483
484#if BOOST_VERSION >= 104500
485template <>
486struct graph_property_type<vtkGraph*>
487{
488 typedef no_property type;
489};
490#endif
491
492template <>
493struct vertex_property_type<vtkGraph*>
494{
495 typedef no_property type;
496};
497
498template <>
499struct edge_property_type<vtkGraph*>
500{
501 typedef no_property type;
502};
503
504#if BOOST_VERSION >= 104500
505template <>
506struct graph_bundle_type<vtkGraph*>
507{
508 typedef no_property type;
509};
510#endif
511
512template <>
513struct vertex_bundle_type<vtkGraph*>
514{
515 typedef no_property type;
516};
517
518template <>
519struct edge_bundle_type<vtkGraph*>
520{
521 typedef no_property type;
522};
523
524inline bool has_no_edges(vtkGraph* g)
525{
526 return ((g->GetNumberOfEdges() > 0) ? false : true);
527}
528
530{
532 {
534 }
536 {
538 }
539}
540
541//===========================================================================
542// vtkDirectedGraph
543
544template <>
546{
547 typedef directed_tag directed_category;
548};
549
550// The graph_traits for a const graph are the same as a non-const graph.
551template <>
553{
554};
555
556// The graph_traits for a const graph are the same as a non-const graph.
557template <>
559{
560};
561
562#if BOOST_VERSION >= 104500
563// Internal graph properties
564template <>
565struct graph_property_type<vtkDirectedGraph*> : graph_property_type<vtkGraph*>
566{
567};
568
569// Internal graph properties
570template <>
571struct graph_property_type<vtkDirectedGraph* const> : graph_property_type<vtkGraph*>
572{
573};
574#endif
575
576// Internal vertex properties
577template <>
579{
580};
581
582// Internal vertex properties
583template <>
584struct vertex_property_type<vtkDirectedGraph* const> : vertex_property_type<vtkGraph*>
585{
586};
587
588// Internal edge properties
589template <>
591{
592};
593
594// Internal edge properties
595template <>
596struct edge_property_type<vtkDirectedGraph* const> : edge_property_type<vtkGraph*>
597{
598};
599
600#if BOOST_VERSION >= 104500
601// Internal graph properties
602template <>
603struct graph_bundle_type<vtkDirectedGraph*> : graph_bundle_type<vtkGraph*>
604{
605};
606
607// Internal graph properties
608template <>
609struct graph_bundle_type<vtkDirectedGraph* const> : graph_bundle_type<vtkGraph*>
610{
611};
612#endif
613
614// Internal vertex properties
615template <>
617{
618};
619
620// Internal vertex properties
621template <>
622struct vertex_bundle_type<vtkDirectedGraph* const> : vertex_bundle_type<vtkGraph*>
623{
624};
625
626// Internal edge properties
627template <>
629{
630};
631
632// Internal edge properties
633template <>
634struct edge_bundle_type<vtkDirectedGraph* const> : edge_bundle_type<vtkGraph*>
635{
636};
637
638//===========================================================================
639// vtkTree
640
641template <>
643{
644};
645
646// The graph_traits for a const graph are the same as a non-const graph.
647template <>
648struct graph_traits<const vtkTree*> : graph_traits<vtkTree*>
649{
650};
651
652// The graph_traits for a const graph are the same as a non-const graph.
653template <>
654struct graph_traits<vtkTree* const> : graph_traits<vtkTree*>
655{
656};
657
658//===========================================================================
659// vtkUndirectedGraph
660template <>
662{
663 typedef undirected_tag directed_category;
664};
665
666// The graph_traits for a const graph are the same as a non-const graph.
667template <>
669{
670};
671
672// The graph_traits for a const graph are the same as a non-const graph.
673template <>
675{
676};
677
678#if BOOST_VERSION >= 104500
679// Internal graph properties
680template <>
681struct graph_property_type<vtkUndirectedGraph*> : graph_property_type<vtkGraph*>
682{
683};
684
685// Internal graph properties
686template <>
687struct graph_property_type<vtkUndirectedGraph* const> : graph_property_type<vtkGraph*>
688{
689};
690#endif
691
692// Internal vertex properties
693template <>
695{
696};
697
698// Internal vertex properties
699template <>
700struct vertex_property_type<vtkUndirectedGraph* const> : vertex_property_type<vtkGraph*>
701{
702};
703
704// Internal edge properties
705template <>
707{
708};
709
710// Internal edge properties
711template <>
712struct edge_property_type<vtkUndirectedGraph* const> : edge_property_type<vtkGraph*>
713{
714};
715
716#if BOOST_VERSION >= 104500
717// Internal graph properties
718template <>
719struct graph_bundle_type<vtkUndirectedGraph*> : graph_bundle_type<vtkGraph*>
720{
721};
722
723// Internal graph properties
724template <>
725struct graph_bundle_type<vtkUndirectedGraph* const> : graph_bundle_type<vtkGraph*>
726{
727};
728#endif
729
730// Internal vertex properties
731template <>
733{
734};
735
736// Internal vertex properties
737template <>
738struct vertex_bundle_type<vtkUndirectedGraph* const> : vertex_bundle_type<vtkGraph*>
739{
740};
741
742// Internal edge properties
743template <>
745{
746};
747
748// Internal edge properties
749template <>
750struct edge_bundle_type<vtkUndirectedGraph* const> : edge_bundle_type<vtkGraph*>
751{
752};
753
754//===========================================================================
755// vtkMutableDirectedGraph
756
757template <>
759{
760};
761
762// The graph_traits for a const graph are the same as a non-const graph.
763template <>
765{
766};
767
768// The graph_traits for a const graph are the same as a non-const graph.
769template <>
771{
772};
773
774#if BOOST_VERSION >= 104500
775// Internal graph properties
776template <>
777struct graph_property_type<vtkMutableDirectedGraph*> : graph_property_type<vtkDirectedGraph*>
778{
779};
780
781// Internal graph properties
782template <>
783struct graph_property_type<vtkMutableDirectedGraph* const> : graph_property_type<vtkDirectedGraph*>
784{
785};
786#endif
787
788// Internal vertex properties
789template <>
791{
792};
793
794// Internal vertex properties
795template <>
796struct vertex_property_type<vtkMutableDirectedGraph* const>
798{
799};
800
801// Internal edge properties
802template <>
804{
805};
806
807// Internal edge properties
808template <>
810{
811};
812
813#if BOOST_VERSION >= 104500
814// Internal graph properties
815template <>
816struct graph_bundle_type<vtkMutableDirectedGraph*> : graph_bundle_type<vtkDirectedGraph*>
817{
818};
819
820// Internal graph properties
821template <>
822struct graph_bundle_type<vtkMutableDirectedGraph* const> : graph_bundle_type<vtkDirectedGraph*>
823{
824};
825#endif
826
827// Internal vertex properties
828template <>
830{
831};
832
833// Internal vertex properties
834template <>
836{
837};
838
839// Internal edge properties
840template <>
842{
843};
844
845// Internal edge properties
846template <>
848{
849};
850
851//===========================================================================
852// vtkMutableUndirectedGraph
853
854template <>
856{
857};
858
859// The graph_traits for a const graph are the same as a non-const graph.
860template <>
862{
863};
864
865// The graph_traits for a const graph are the same as a non-const graph.
866template <>
868{
869};
870
871#if BOOST_VERSION >= 104500
872// Internal graph properties
873template <>
874struct graph_property_type<vtkMutableUndirectedGraph*> : graph_property_type<vtkUndirectedGraph*>
875{
876};
877
878// Internal graph properties
879template <>
880struct graph_property_type<vtkMutableUndirectedGraph* const>
881 : graph_property_type<vtkUndirectedGraph*>
882{
883};
884#endif
885
886// Internal vertex properties
887template <>
889{
890};
891
892// Internal vertex properties
893template <>
894struct vertex_property_type<vtkMutableUndirectedGraph* const>
896{
897};
898
899// Internal edge properties
900template <>
902{
903};
904
905// Internal edge properties
906template <>
907struct edge_property_type<vtkMutableUndirectedGraph* const>
909{
910};
911
912#if BOOST_VERSION >= 104500
913// Internal graph properties
914template <>
915struct graph_bundle_type<vtkMutableUndirectedGraph*> : graph_bundle_type<vtkUndirectedGraph*>
916{
917};
918
919// Internal graph properties
920template <>
921struct graph_bundle_type<vtkMutableUndirectedGraph* const> : graph_bundle_type<vtkUndirectedGraph*>
922{
923};
924#endif
925
926// Internal vertex properties
927template <>
929{
930};
931
932// Internal vertex properties
933template <>
934struct vertex_bundle_type<vtkMutableUndirectedGraph* const>
936{
937};
938
939// Internal edge properties
940template <>
942{
943};
944
945// Internal edge properties
946template <>
948{
949};
950
951//===========================================================================
952// API implementation
953template <>
954class vertex_property<vtkGraph*>
955{
956public:
958};
959
960template <>
961class edge_property<vtkGraph*>
962{
963public:
965};
966} // end namespace boost
967
970{
971 return e.Source;
972}
973
976{
977 return e.Target;
978}
979
980inline std::pair<boost::graph_traits<vtkGraph*>::vertex_iterator,
983{
985 vtkIdType start = 0;
987 {
989 start = helper->MakeDistributedId(rank, start);
990 }
991
992 return std::make_pair(Iter(start), Iter(start + g->GetNumberOfVertices()));
993}
994
995inline std::pair<boost::graph_traits<vtkGraph*>::edge_iterator,
998{
1000 return std::make_pair(Iter(g), Iter(g, g->GetNumberOfVertices()));
1001}
1002
1003inline std::pair<boost::graph_traits<vtkGraph*>::out_edge_iterator,
1006{
1008 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u, true));
1009 return p;
1010}
1011
1012inline std::pair<boost::graph_traits<vtkGraph*>::in_edge_iterator,
1015{
1017 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u, true));
1018 return p;
1019}
1020
1021inline std::pair<boost::graph_traits<vtkGraph*>::adjacency_iterator,
1024{
1027 std::pair<OutEdgeIter, OutEdgeIter> out = out_edges(u, g);
1028 return std::make_pair(Iter(out.first, &g), Iter(out.second, &g));
1029}
1030
1032{
1033 return g->GetNumberOfVertices();
1034}
1035
1037{
1038 return g->GetNumberOfEdges();
1039}
1040
1043{
1044 return g->GetOutDegree(u);
1045}
1046
1049{
1050 return g->GetInDegree(u);
1051}
1052
1055{
1056 return g->GetDegree(u);
1057}
1058
1061{
1062 return g->AddVertex();
1063}
1064
1065inline std::pair<boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor, bool> add_edge(
1068{
1070 return std::make_pair(e, true);
1071}
1072
1075{
1076 return g->AddVertex();
1077}
1078
1079inline std::pair<boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor, bool> add_edge(
1083{
1085 return std::make_pair(e, true);
1086}
1087
1088namespace boost
1089{
1090//===========================================================================
1091// An edge map for vtkGraph.
1092// This is a common input needed for algorithms.
1093
1095{
1096};
1097
1098template <>
1100{
1104 typedef readable_property_map_tag category;
1105};
1106
1109{
1110 return key.Id;
1111}
1112
1113//===========================================================================
1114// Helper for vtkGraph edge property maps
1115// Automatically converts boost edge ids to vtkGraph edge ids.
1116
1117template <typename PMap>
1119{
1120public:
1122 : pmap(m)
1123 {
1124 }
1125 PMap pmap;
1130
1131 reference operator[](const key_type& key) const { return get(pmap, key.Id); }
1132};
1133
1134template <typename PMap>
1137{
1138 return get(helper.pmap, key.Id);
1139}
1140
1141template <typename PMap>
1144{
1145 put(helper.pmap, key.Id, value);
1146}
1147
1148//===========================================================================
1149// Helper for vtkGraph vertex property maps
1150// Automatically converts boost vertex ids to vtkGraph vertex ids.
1151
1152template <typename PMap>
1154{
1155public:
1157 : pmap(m)
1158 {
1159 }
1160 PMap pmap;
1165
1166 reference operator[](const key_type& key) const { return get(pmap, key); }
1167};
1168
1169template <typename PMap>
1172{
1173 return get(helper.pmap, key);
1174}
1175
1176template <typename PMap>
1179{
1180 put(helper.pmap, key, value);
1181}
1182
1183//===========================================================================
1184// An index map for vtkGraph
1185// This is a common input needed for algorithms
1186
1188{
1189};
1190
1191template <>
1193{
1197 typedef readable_property_map_tag category;
1198};
1199
1202{
1203 return key;
1204}
1205
1206//===========================================================================
1207// Helper for vtkGraph property maps
1208// Automatically multiplies the property value by some value (default 1)
1209template <typename PMap>
1211{
1212public:
1213 vtkGraphPropertyMapMultiplier(PMap m, float multi = 1)
1214 : pmap(m)
1215 , multiplier(multi)
1216 {
1217 }
1218 PMap pmap;
1224};
1225
1226template <typename PMap>
1229{
1230 return multi.multiplier * get(multi.pmap, key);
1231}
1232
1233template <typename PMap>
1235 const typename property_traits<PMap>::key_type& key,
1237{
1238 put(multi.pmap, key, value);
1239}
1240
1241// Allow algorithms to automatically extract vtkGraphIndexMap from a
1242// VTK graph
1243template <>
1244struct property_map<vtkGraph*, vertex_index_t>
1245{
1248};
1249
1250template <>
1251struct property_map<vtkDirectedGraph*, vertex_index_t> : property_map<vtkGraph*, vertex_index_t>
1252{
1253};
1254
1255template <>
1257{
1258};
1259
1260inline vtkGraphIndexMap get(vertex_index_t, vtkGraph*)
1261{
1262 return vtkGraphIndexMap();
1263}
1264
1265template <>
1266struct property_map<vtkGraph*, edge_index_t>
1267{
1270};
1271
1272template <>
1273struct property_map<vtkDirectedGraph*, edge_index_t> : property_map<vtkGraph*, edge_index_t>
1274{
1275};
1276
1277template <>
1279{
1280};
1281
1282inline vtkGraphIndexMap get(edge_index_t, vtkGraph*)
1283{
1284 return vtkGraphIndexMap();
1285}
1286
1287// property_map specializations for const-qualified graphs
1288template <>
1289struct property_map<vtkDirectedGraph* const, vertex_index_t>
1291{
1292};
1293
1294template <>
1295struct property_map<vtkUndirectedGraph* const, vertex_index_t>
1297{
1298};
1299
1300template <>
1301struct property_map<vtkDirectedGraph* const, edge_index_t>
1303{
1304};
1305
1306template <>
1307struct property_map<vtkUndirectedGraph* const, edge_index_t>
1309{
1310};
1311} // namespace boost
1312
1313#if BOOST_VERSION > 104000
1314#include <boost/property_map/vector_property_map.hpp>
1315#else
1316#include <boost/vector_property_map.hpp>
1317#endif
1318
1319#endif // vtkBoostGraphAdapter_h
1320// VTK-HeaderTest-Exclude: vtkBoostGraphAdapter.h
property_traits< PMap >::reference reference
property_traits< PMap >::category category
property_traits< PMap >::value_type value_type
reference operator[](const key_type &key) const
vtkGraphPropertyMapMultiplier(PMap m, float multi=1)
property_traits< PMap >::value_type value_type
property_traits< PMap >::reference reference
property_traits< PMap >::key_type key_type
property_traits< PMap >::category category
property_traits< PMap >::reference reference
property_traits< PMap >::value_type value_type
reference operator[](const key_type &key) const
property_traits< PMap >::category category
vtk_edge_iterator(vtkGraph *g=0, vtkIdType v=0)
vtk_in_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
vtk_out_edge_pointer_iterator(vtkGraph *g=0, vtkIdType v=0, bool end=false)
Abstract superclass for all arrays.
virtual vtkVariant GetVariantValue(vtkIdType valueIdx)
Retrieve value from the array as a variant.
virtual void InsertVariantValue(vtkIdType valueIdx, vtkVariant value)=0
Insert a value into the array from a variant.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
void SetTuple1(vtkIdType tupleIdx, double value)
These methods are included as convenience for the wrappers.
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
virtual vtkInformation * GetInformation()
Set/Get the information object associated with this data object.
static vtkInformationIntegerKey * DATA_PIECE_NUMBER()
A directed graph.
static vtkDirectedGraph * SafeDownCast(vtkObjectBase *o)
helper for the vtkGraph class that allows the graph to be distributed across multiple memory spaces.
vtkIdType GetEdgeOwner(vtkIdType e_id) const
Returns owner of edge with ID e_id, by extracting top ceil(log2 P) bits of e_id.
vtkIdType MakeDistributedId(int owner, vtkIdType local)
Builds a distributed ID consisting of the given owner and the local ID.
vtkIdType GetVertexOwner(vtkIdType v) const
Returns owner of vertex v, by extracting top ceil(log2 P) bits of v.
dynamic, self-adjusting array of double
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
Base class for graph data types.
Definition: vtkGraph.h:299
virtual vtkIdType GetOutDegree(vtkIdType v)
The number of outgoing edges from vertex v.
virtual vtkIdType GetNumberOfVertices()
The number of vertices in the graph.
virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it)
Initializes the out edge iterator to iterate over all outgoing edges of vertex v.
vtkDistributedGraphHelper * GetDistributedGraphHelper()
Retrieves the distributed graph helper for this graph.
virtual vtkIdType GetNumberOfEdges()
The number of edges in the graph.
virtual vtkIdType GetInDegree(vtkIdType v)
The number of incoming edges to vertex v.
virtual vtkIdType GetDegree(vtkIdType v)
The total of all incoming and outgoing vertices for vertex v.
dynamic, self-adjusting array of vtkIdType
int Get(vtkInformationIntegerKey *key)
Get/Set an integer-valued entry.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
An editable directed graph.
void RemoveEdge(vtkIdType e)
Removes the edge from the graph.
static vtkMutableDirectedGraph * SafeDownCast(vtkObjectBase *o)
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
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...
An editable undirected graph.
static vtkMutableUndirectedGraph * SafeDownCast(vtkObjectBase *o)
void RemoveEdge(vtkIdType e)
Removes the edge from the graph.
vtkIdType AddVertex()
Adds a vertex to the graph and returns the index of the new vertex.
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...
A rooted tree data structure.
Definition: vtkTree.h:64
An undirected graph.
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
Forward declaration required for Boost serialization.
bool has_no_edges(vtkGraph *g)
vtkPropertyMapMacro(vtkIntArray, int)
void remove_edge(graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *g)
vtkGraphIndexMap get(edge_index_t, vtkGraph *)
void put(vtkGraphPropertyMapMultiplier< PMap > multi, const typename property_traits< PMap >::key_type &key, const typename property_traits< PMap >::value_type &value)
double get(vtkDataArray *const &arr, vtkIdType key)
void put(vtkDataArray *arr, vtkIdType key, const double &value)
@ key
Definition: vtkX3D.h:263
@ value
Definition: vtkX3D.h:226
@ type
Definition: vtkX3D.h:522
vtk_in_edge_pointer_iterator in_edge_iterator
allow_parallel_edge_tag edge_parallel_category
vtk_out_edge_pointer_iterator out_edge_iterator
static vertex_descriptor null_vertex()
adjacency_iterator_generator< vtkGraph *, vertex_descriptor, out_edge_iterator >::type adjacency_iterator
vtkGraph_traversal_category traversal_category
vtkIdType Id
Definition: vtkGraph.h:260
vtkIdType Source
Definition: vtkGraph.h:282
vtkIdType Target
Definition: vtkGraph.h:271
boost::graph_traits< vtkDirectedGraph * >::degree_size_type in_degree(boost::graph_traits< vtkDirectedGraph * >::vertex_descriptor u, vtkDirectedGraph *g)
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
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)
boost::graph_traits< vtkGraph * >::vertices_size_type num_vertices(vtkGraph *g)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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)
std::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
boost::graph_traits< vtkMutableDirectedGraph * >::vertex_descriptor add_vertex(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)
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 target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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< vtkGraph * >::edges_size_type num_edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:332