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-------------------------------------------------------------------------*/
30#ifndef vtkBoostGraphAdapter_h
31#define vtkBoostGraphAdapter_h
32
33#include "vtkAbstractArray.h"
34#include "vtkDataArray.h"
35#include "vtkDataObject.h"
36#include "vtkDirectedGraph.h"
38#include "vtkDoubleArray.h"
39#include "vtkFloatArray.h"
40#include "vtkIdTypeArray.h"
41#include "vtkInformation.h"
42#include "vtkIntArray.h"
45#include "vtkTree.h"
46#include "vtkUndirectedGraph.h"
47#include "vtkVariant.h"
48
49#include <boost/version.hpp>
50
51namespace boost
52{
53//===========================================================================
54// VTK arrays as property maps
55// These need to be defined before including other boost stuff
56
57// Forward declarations are required here, so that we aren't forced
58// to include boost/property_map.hpp.
59template <typename>
61struct read_write_property_map_tag;
62
63#define vtkPropertyMapMacro(T, V) \
64 template <> \
65 struct property_traits<T*> \
66 { \
67 typedef V value_type; \
68 typedef V reference; \
69 typedef vtkIdType key_type; \
70 typedef read_write_property_map_tag category; \
71 }; \
72 \
73 inline property_traits<T*>::reference get(T* const& arr, property_traits<T*>::key_type key) \
74 { \
75 return arr->GetValue(key); \
76 } \
77 \
78 inline void put( \
79 T* arr, property_traits<T*>::key_type key, const property_traits<T*>::value_type& value) \
80 { \
81 arr->InsertValue(key, value); \
82 }
83
88
89// vtkDataArray
90template <>
92{
93 typedef double value_type;
94 typedef double reference;
96 typedef read_write_property_map_tag category;
97};
98
99inline double get(vtkDataArray* const& arr, vtkIdType key)
100{
101 return arr->GetTuple1(key);
102}
103
104inline void put(vtkDataArray* arr, vtkIdType key, const double& value)
105{
106 arr->SetTuple1(key, value);
107}
108
109// vtkAbstractArray as a property map of vtkVariants
110template <>
112{
116 typedef read_write_property_map_tag category;
117};
118
120{
121 return arr->GetVariantValue(key);
122}
123
125{
127}
128#if defined(_MSC_VER)
129namespace detail
130{
133}
134#endif
135}
136
137#include <utility> // STL Header
138
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>
144
145// The functions and classes in this file allows the user to
146// treat a vtkDirectedGraph or vtkUndirectedGraph object
147// as a boost graph "as is".
148
149namespace boost
150{
151
153 : public iterator_facade<vtk_vertex_iterator, vtkIdType, bidirectional_traversal_tag,
154 const vtkIdType&, vtkIdType>
155{
156public:
158 : index(i)
159 {
160 }
161
162private:
163 const vtkIdType& dereference() const { return index; }
164
165 bool equal(const vtk_vertex_iterator& other) const { return index == other.index; }
166
167 void increment() { index++; }
168 void decrement() { index--; }
169
170 vtkIdType index;
171
173};
174
176 : public iterator_facade<vtk_edge_iterator, vtkEdgeType, forward_traversal_tag,
177 const vtkEdgeType&, vtkIdType>
178{
179public:
180 explicit vtk_edge_iterator(vtkGraph* g = 0, vtkIdType v = 0)
181 : directed(false)
182 , vertex(v)
183 , lastVertex(v)
184 , iter(nullptr)
185 , end(nullptr)
186 , graph(g)
187 {
188 if (graph)
189 {
190 lastVertex = graph->GetNumberOfVertices();
191 }
192
193 vtkIdType myRank = -1;
194 vtkDistributedGraphHelper* helper = this->graph ? this->graph->GetDistributedGraphHelper() : 0;
195 if (helper)
196 {
197 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
198 vertex = helper->MakeDistributedId(myRank, vertex);
199 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
200 }
201
202 if (graph != 0)
203 {
204 directed = (vtkDirectedGraph::SafeDownCast(graph) != 0);
205 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
206 {
207 ++vertex;
208 }
209
210 if (vertex < lastVertex)
211 {
212 // Get the outgoing edges of the first vertex that has outgoing
213 // edges
214 vtkIdType nedges;
215 graph->GetOutEdges(vertex, iter, nedges);
216 if (iter)
217 {
218 end = iter + nedges;
219
220 if (!directed)
221 {
222 while ( // Skip non-local edges
223 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
224 // Skip entirely-local edges where Source > Target
225 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
226 vertex > iter->Target))
227 {
228 this->inc();
229 }
230 }
231 }
232 }
233 else
234 {
235 iter = nullptr;
236 }
237 }
238
239 RecalculateEdge();
240 }
241
242private:
243 const vtkEdgeType& dereference() const
244 {
245 assert(iter);
246 return edge;
247 }
248
249 bool equal(const vtk_edge_iterator& other) const
250 {
251 return vertex == other.vertex && iter == other.iter;
252 }
253
254 void increment()
255 {
256 inc();
257 if (!directed)
258 {
259 vtkIdType myRank = -1;
261 this->graph ? this->graph->GetDistributedGraphHelper() : 0;
262 if (helper)
263 {
264 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
265 }
266
267 while (iter != 0 &&
268 ( // Skip non-local edges
269 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
270 // Skip entirely-local edges where Source > Target
271 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
272 vertex > iter->Target)))
273 {
274 inc();
275 }
276 }
277 RecalculateEdge();
278 }
279
280 void inc()
281 {
282 ++iter;
283 if (iter == end)
284 {
285 // Find a vertex with nonzero out degree.
286 ++vertex;
287 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
288 {
289 ++vertex;
290 }
291
292 if (vertex < lastVertex)
293 {
294 vtkIdType nedges;
295 graph->GetOutEdges(vertex, iter, nedges);
296 end = iter + nedges;
297 }
298 else
299 {
300 iter = nullptr;
301 }
302 }
303 }
304
305 void RecalculateEdge()
306 {
307 if (iter)
308 {
309 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
310 }
311 }
312
313 bool directed;
314 vtkIdType vertex;
315 vtkIdType lastVertex;
316 const vtkOutEdgeType* iter;
317 const vtkOutEdgeType* end;
318 vtkGraph* graph;
319 vtkEdgeType edge;
320
322};
323
325 : public iterator_facade<vtk_out_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
326 const vtkEdgeType&, ptrdiff_t>
327{
328public:
329 explicit vtk_out_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
330 : vertex(v)
331 , iter(nullptr)
332 {
333 if (g)
334 {
335 vtkIdType nedges;
336 g->GetOutEdges(vertex, iter, nedges);
337 if (end)
338 {
339 iter += nedges;
340 }
341 }
342 RecalculateEdge();
343 }
344
345private:
346 const vtkEdgeType& dereference() const
347 {
348 assert(iter);
349 return edge;
350 }
351
352 bool equal(const vtk_out_edge_pointer_iterator& other) const { return iter == other.iter; }
353
354 void increment()
355 {
356 iter++;
357 RecalculateEdge();
358 }
359
360 void decrement()
361 {
362 iter--;
363 RecalculateEdge();
364 }
365
366 void RecalculateEdge()
367 {
368 if (iter)
369 {
370 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
371 }
372 }
373
374 vtkIdType vertex;
375 const vtkOutEdgeType* iter;
376 vtkEdgeType edge;
377
379};
380
382 : public iterator_facade<vtk_in_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
383 const vtkEdgeType&, ptrdiff_t>
384{
385public:
386 explicit vtk_in_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
387 : vertex(v)
388 , iter(nullptr)
389 {
390 if (g)
391 {
392 vtkIdType nedges;
393 g->GetInEdges(vertex, iter, nedges);
394 if (end)
395 {
396 iter += nedges;
397 }
398 }
399 RecalculateEdge();
400 }
401
402private:
403 const vtkEdgeType& dereference() const
404 {
405 assert(iter);
406 return edge;
407 }
408
409 bool equal(const vtk_in_edge_pointer_iterator& other) const { return iter == other.iter; }
410
411 void increment()
412 {
413 iter++;
414 RecalculateEdge();
415 }
416
417 void decrement()
418 {
419 iter--;
420 RecalculateEdge();
421 }
422
423 void RecalculateEdge()
424 {
425 if (iter)
426 {
427 edge = vtkEdgeType(iter->Source, vertex, iter->Id);
428 }
429 }
430
431 vtkIdType vertex;
432 const vtkInEdgeType* iter;
433 vtkEdgeType edge;
434
436};
437
438//===========================================================================
439// vtkGraph
440// VertexAndEdgeListGraphConcept
441// BidirectionalGraphConcept
442// AdjacencyGraphConcept
443
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
449{
450};
451
452template <>
453struct graph_traits<vtkGraph*>
454{
456 static vertex_descriptor null_vertex() { return -1; }
458 static edge_descriptor null_edge() { return vtkEdgeType(-1, -1, -1); }
461
464
465 typedef allow_parallel_edge_tag edge_parallel_category;
470
473};
474
475#if BOOST_VERSION >= 104500
476template <>
477struct graph_property_type<vtkGraph*>
478{
479 typedef no_property type;
480};
481#endif
482
483template <>
484struct vertex_property_type<vtkGraph*>
485{
486 typedef no_property type;
487};
488
489template <>
490struct edge_property_type<vtkGraph*>
491{
492 typedef no_property type;
493};
494
495#if BOOST_VERSION >= 104500
496template <>
497struct graph_bundle_type<vtkGraph*>
498{
499 typedef no_property type;
500};
501#endif
502
503template <>
504struct vertex_bundle_type<vtkGraph*>
505{
506 typedef no_property type;
507};
508
509template <>
510struct edge_bundle_type<vtkGraph*>
511{
512 typedef no_property type;
513};
514
515inline bool has_no_edges(vtkGraph* g)
516{
517 return ((g->GetNumberOfEdges() > 0) ? false : true);
518}
519
521{
523 {
525 }
527 {
529 }
530}
531
532//===========================================================================
533// vtkDirectedGraph
534
535template <>
537{
538 typedef directed_tag directed_category;
539};
540
541// The graph_traits for a const graph are the same as a non-const graph.
542template <>
544{
545};
546
547// The graph_traits for a const graph are the same as a non-const graph.
548template <>
550{
551};
552
553#if BOOST_VERSION >= 104500
554// Internal graph properties
555template <>
556struct graph_property_type<vtkDirectedGraph*> : graph_property_type<vtkGraph*>
557{
558};
559
560// Internal graph properties
561template <>
562struct graph_property_type<vtkDirectedGraph* const> : graph_property_type<vtkGraph*>
563{
564};
565#endif
566
567// Internal vertex properties
568template <>
570{
571};
572
573// Internal vertex properties
574template <>
575struct vertex_property_type<vtkDirectedGraph* const> : vertex_property_type<vtkGraph*>
576{
577};
578
579// Internal edge properties
580template <>
582{
583};
584
585// Internal edge properties
586template <>
587struct edge_property_type<vtkDirectedGraph* const> : edge_property_type<vtkGraph*>
588{
589};
590
591#if BOOST_VERSION >= 104500
592// Internal graph properties
593template <>
594struct graph_bundle_type<vtkDirectedGraph*> : graph_bundle_type<vtkGraph*>
595{
596};
597
598// Internal graph properties
599template <>
600struct graph_bundle_type<vtkDirectedGraph* const> : graph_bundle_type<vtkGraph*>
601{
602};
603#endif
604
605// Internal vertex properties
606template <>
608{
609};
610
611// Internal vertex properties
612template <>
613struct vertex_bundle_type<vtkDirectedGraph* const> : vertex_bundle_type<vtkGraph*>
614{
615};
616
617// Internal edge properties
618template <>
620{
621};
622
623// Internal edge properties
624template <>
625struct edge_bundle_type<vtkDirectedGraph* const> : edge_bundle_type<vtkGraph*>
626{
627};
628
629//===========================================================================
630// vtkTree
631
632template <>
634{
635};
636
637// The graph_traits for a const graph are the same as a non-const graph.
638template <>
639struct graph_traits<const vtkTree*> : graph_traits<vtkTree*>
640{
641};
642
643// The graph_traits for a const graph are the same as a non-const graph.
644template <>
645struct graph_traits<vtkTree* const> : graph_traits<vtkTree*>
646{
647};
648
649//===========================================================================
650// vtkUndirectedGraph
651template <>
653{
654 typedef undirected_tag directed_category;
655};
656
657// The graph_traits for a const graph are the same as a non-const graph.
658template <>
660{
661};
662
663// The graph_traits for a const graph are the same as a non-const graph.
664template <>
666{
667};
668
669#if BOOST_VERSION >= 104500
670// Internal graph properties
671template <>
672struct graph_property_type<vtkUndirectedGraph*> : graph_property_type<vtkGraph*>
673{
674};
675
676// Internal graph properties
677template <>
678struct graph_property_type<vtkUndirectedGraph* const> : graph_property_type<vtkGraph*>
679{
680};
681#endif
682
683// Internal vertex properties
684template <>
686{
687};
688
689// Internal vertex properties
690template <>
691struct vertex_property_type<vtkUndirectedGraph* const> : vertex_property_type<vtkGraph*>
692{
693};
694
695// Internal edge properties
696template <>
698{
699};
700
701// Internal edge properties
702template <>
703struct edge_property_type<vtkUndirectedGraph* const> : edge_property_type<vtkGraph*>
704{
705};
706
707#if BOOST_VERSION >= 104500
708// Internal graph properties
709template <>
710struct graph_bundle_type<vtkUndirectedGraph*> : graph_bundle_type<vtkGraph*>
711{
712};
713
714// Internal graph properties
715template <>
716struct graph_bundle_type<vtkUndirectedGraph* const> : graph_bundle_type<vtkGraph*>
717{
718};
719#endif
720
721// Internal vertex properties
722template <>
724{
725};
726
727// Internal vertex properties
728template <>
729struct vertex_bundle_type<vtkUndirectedGraph* const> : vertex_bundle_type<vtkGraph*>
730{
731};
732
733// Internal edge properties
734template <>
736{
737};
738
739// Internal edge properties
740template <>
741struct edge_bundle_type<vtkUndirectedGraph* const> : edge_bundle_type<vtkGraph*>
742{
743};
744
745//===========================================================================
746// vtkMutableDirectedGraph
747
748template <>
750{
751};
752
753// The graph_traits for a const graph are the same as a non-const graph.
754template <>
756{
757};
758
759// The graph_traits for a const graph are the same as a non-const graph.
760template <>
762{
763};
764
765#if BOOST_VERSION >= 104500
766// Internal graph properties
767template <>
768struct graph_property_type<vtkMutableDirectedGraph*> : graph_property_type<vtkDirectedGraph*>
769{
770};
771
772// Internal graph properties
773template <>
774struct graph_property_type<vtkMutableDirectedGraph* const> : graph_property_type<vtkDirectedGraph*>
775{
776};
777#endif
778
779// Internal vertex properties
780template <>
782{
783};
784
785// Internal vertex properties
786template <>
787struct vertex_property_type<vtkMutableDirectedGraph* const>
789{
790};
791
792// Internal edge properties
793template <>
795{
796};
797
798// Internal edge properties
799template <>
801{
802};
803
804#if BOOST_VERSION >= 104500
805// Internal graph properties
806template <>
807struct graph_bundle_type<vtkMutableDirectedGraph*> : graph_bundle_type<vtkDirectedGraph*>
808{
809};
810
811// Internal graph properties
812template <>
813struct graph_bundle_type<vtkMutableDirectedGraph* const> : graph_bundle_type<vtkDirectedGraph*>
814{
815};
816#endif
817
818// Internal vertex properties
819template <>
821{
822};
823
824// Internal vertex properties
825template <>
827{
828};
829
830// Internal edge properties
831template <>
833{
834};
835
836// Internal edge properties
837template <>
839{
840};
841
842//===========================================================================
843// vtkMutableUndirectedGraph
844
845template <>
847{
848};
849
850// The graph_traits for a const graph are the same as a non-const graph.
851template <>
853{
854};
855
856// The graph_traits for a const graph are the same as a non-const graph.
857template <>
859{
860};
861
862#if BOOST_VERSION >= 104500
863// Internal graph properties
864template <>
865struct graph_property_type<vtkMutableUndirectedGraph*> : graph_property_type<vtkUndirectedGraph*>
866{
867};
868
869// Internal graph properties
870template <>
871struct graph_property_type<vtkMutableUndirectedGraph* const>
872 : graph_property_type<vtkUndirectedGraph*>
873{
874};
875#endif
876
877// Internal vertex properties
878template <>
880{
881};
882
883// Internal vertex properties
884template <>
885struct vertex_property_type<vtkMutableUndirectedGraph* const>
887{
888};
889
890// Internal edge properties
891template <>
893{
894};
895
896// Internal edge properties
897template <>
898struct edge_property_type<vtkMutableUndirectedGraph* const>
900{
901};
902
903#if BOOST_VERSION >= 104500
904// Internal graph properties
905template <>
906struct graph_bundle_type<vtkMutableUndirectedGraph*> : graph_bundle_type<vtkUndirectedGraph*>
907{
908};
909
910// Internal graph properties
911template <>
912struct graph_bundle_type<vtkMutableUndirectedGraph* const> : graph_bundle_type<vtkUndirectedGraph*>
913{
914};
915#endif
916
917// Internal vertex properties
918template <>
920{
921};
922
923// Internal vertex properties
924template <>
925struct vertex_bundle_type<vtkMutableUndirectedGraph* const>
927{
928};
929
930// Internal edge properties
931template <>
933{
934};
935
936// Internal edge properties
937template <>
939{
940};
941
942//===========================================================================
943// API implementation
944template <>
945class vertex_property<vtkGraph*>
946{
947public:
949};
950
951template <>
952class edge_property<vtkGraph*>
953{
954public:
956};
957} // end namespace boost
958
961{
962 return e.Source;
963}
964
967{
968 return e.Target;
969}
970
971inline std::pair<boost::graph_traits<vtkGraph*>::vertex_iterator,
974{
976 vtkIdType start = 0;
978 {
980 start = helper->MakeDistributedId(rank, start);
981 }
982
983 return std::make_pair(Iter(start), Iter(start + g->GetNumberOfVertices()));
984}
985
986inline std::pair<boost::graph_traits<vtkGraph*>::edge_iterator,
989{
991 return std::make_pair(Iter(g), Iter(g, g->GetNumberOfVertices()));
992}
993
994inline std::pair<boost::graph_traits<vtkGraph*>::out_edge_iterator,
997{
999 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u, true));
1000 return p;
1001}
1002
1003inline std::pair<boost::graph_traits<vtkGraph*>::in_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*>::adjacency_iterator,
1015{
1018 std::pair<OutEdgeIter, OutEdgeIter> out = out_edges(u, g);
1019 return std::make_pair(Iter(out.first, &g), Iter(out.second, &g));
1020}
1021
1023{
1024 return g->GetNumberOfVertices();
1025}
1026
1028{
1029 return g->GetNumberOfEdges();
1030}
1031
1034{
1035 return g->GetOutDegree(u);
1036}
1037
1040{
1041 return g->GetInDegree(u);
1042}
1043
1046{
1047 return g->GetDegree(u);
1048}
1049
1052{
1053 return g->AddVertex();
1054}
1055
1056inline std::pair<boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor, bool> add_edge(
1059{
1061 return std::make_pair(e, true);
1062}
1063
1066{
1067 return g->AddVertex();
1068}
1069
1070inline std::pair<boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor, bool> add_edge(
1074{
1076 return std::make_pair(e, true);
1077}
1078
1079namespace boost
1080{
1081//===========================================================================
1082// An edge map for vtkGraph.
1083// This is a common input needed for algorithms.
1084
1086{
1087};
1088
1089template <>
1091{
1095 typedef readable_property_map_tag category;
1096};
1097
1100{
1101 return key.Id;
1102}
1103
1104//===========================================================================
1105// Helper for vtkGraph edge property maps
1106// Automatically converts boost edge ids to vtkGraph edge ids.
1107
1108template <typename PMap>
1110{
1111public:
1113 : pmap(m)
1114 {
1115 }
1116 PMap pmap;
1121
1122 reference operator[](const key_type& key) const { return get(pmap, key.Id); }
1123};
1124
1125template <typename PMap>
1128{
1129 return get(helper.pmap, key.Id);
1130}
1131
1132template <typename PMap>
1135{
1136 put(helper.pmap, key.Id, value);
1137}
1138
1139//===========================================================================
1140// Helper for vtkGraph vertex property maps
1141// Automatically converts boost vertex ids to vtkGraph vertex ids.
1142
1143template <typename PMap>
1145{
1146public:
1148 : pmap(m)
1149 {
1150 }
1151 PMap pmap;
1156
1157 reference operator[](const key_type& key) const { return get(pmap, key); }
1158};
1159
1160template <typename PMap>
1163{
1164 return get(helper.pmap, key);
1165}
1166
1167template <typename PMap>
1170{
1171 put(helper.pmap, key, value);
1172}
1173
1174//===========================================================================
1175// An index map for vtkGraph
1176// This is a common input needed for algorithms
1177
1179{
1180};
1181
1182template <>
1184{
1188 typedef readable_property_map_tag category;
1189};
1190
1193{
1194 return key;
1195}
1196
1197//===========================================================================
1198// Helper for vtkGraph property maps
1199// Automatically multiplies the property value by some value (default 1)
1200template <typename PMap>
1202{
1203public:
1204 vtkGraphPropertyMapMultiplier(PMap m, float multi = 1)
1205 : pmap(m)
1206 , multiplier(multi)
1207 {
1208 }
1209 PMap pmap;
1215};
1216
1217template <typename PMap>
1220{
1221 return multi.multiplier * get(multi.pmap, key);
1222}
1223
1224template <typename PMap>
1226 const typename property_traits<PMap>::key_type& key,
1228{
1229 put(multi.pmap, key, value);
1230}
1231
1232// Allow algorithms to automatically extract vtkGraphIndexMap from a
1233// VTK graph
1234template <>
1235struct property_map<vtkGraph*, vertex_index_t>
1236{
1239};
1240
1241template <>
1242struct property_map<vtkDirectedGraph*, vertex_index_t> : property_map<vtkGraph*, vertex_index_t>
1243{
1244};
1245
1246template <>
1248{
1249};
1250
1251inline vtkGraphIndexMap get(vertex_index_t, vtkGraph*)
1252{
1253 return vtkGraphIndexMap();
1254}
1255
1256template <>
1257struct property_map<vtkGraph*, edge_index_t>
1258{
1261};
1262
1263template <>
1264struct property_map<vtkDirectedGraph*, edge_index_t> : property_map<vtkGraph*, edge_index_t>
1265{
1266};
1267
1268template <>
1270{
1271};
1272
1273inline vtkGraphIndexMap get(edge_index_t, vtkGraph*)
1274{
1275 return vtkGraphIndexMap();
1276}
1277
1278// property_map specializations for const-qualified graphs
1279template <>
1280struct property_map<vtkDirectedGraph* const, vertex_index_t>
1282{
1283};
1284
1285template <>
1286struct property_map<vtkUndirectedGraph* const, vertex_index_t>
1288{
1289};
1290
1291template <>
1292struct property_map<vtkDirectedGraph* const, edge_index_t>
1294{
1295};
1296
1297template <>
1298struct property_map<vtkUndirectedGraph* const, edge_index_t>
1300{
1301};
1302} // namespace boost
1303
1304#if BOOST_VERSION > 104000
1305#include <boost/property_map/vector_property_map.hpp>
1306#else
1307#include <boost/vector_property_map.hpp>
1308#endif
1309
1310#endif // vtkBoostGraphAdapter_h
1311// 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:50
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:36
Base class for graph data types.
Definition: vtkGraph.h:290
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:40
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:55
An undirected graph.
A atomic type representing the union of many types.
Definition: vtkVariant.h:66
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:251
vtkIdType Source
Definition: vtkGraph.h:273
vtkIdType Target
Definition: vtkGraph.h:262
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