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-------------------------------------------------------------------------*/
69#ifndef vtkBoostGraphAdapter_h
70#define vtkBoostGraphAdapter_h
71
72#include "vtkAbstractArray.h"
73#include "vtkDataArray.h"
74#include "vtkDataObject.h"
75#include "vtkDirectedGraph.h"
77#include "vtkDoubleArray.h"
78#include "vtkFloatArray.h"
79#include "vtkIdTypeArray.h"
80#include "vtkInformation.h"
81#include "vtkIntArray.h"
84#include "vtkTree.h"
85#include "vtkUndirectedGraph.h"
86#include "vtkVariant.h"
87
88#include <boost/version.hpp>
89
90namespace boost
91{
92//===========================================================================
93// VTK arrays as property maps
94// These need to be defined before including other boost stuff
95
96// Forward declarations are required here, so that we aren't forced
97// to include boost/property_map.hpp.
98template <typename>
100struct read_write_property_map_tag;
101
102#define vtkPropertyMapMacro(T, V) \
103 template <> \
104 struct property_traits<T*> \
105 { \
106 typedef V value_type; \
107 typedef V reference; \
108 typedef vtkIdType key_type; \
109 typedef read_write_property_map_tag category; \
110 }; \
111 \
112 inline property_traits<T*>::reference get(T* const& arr, property_traits<T*>::key_type key) \
113 { \
114 return arr->GetValue(key); \
115 } \
116 \
117 inline void put( \
118 T* arr, property_traits<T*>::key_type key, const property_traits<T*>::value_type& value) \
119 { \
120 arr->InsertValue(key, value); \
121 }
122
127
128// vtkDataArray
129template <>
131{
132 typedef double value_type;
133 typedef double reference;
135 typedef read_write_property_map_tag category;
136};
137
138inline double get(vtkDataArray* const& arr, vtkIdType key)
139{
140 return arr->GetTuple1(key);
141}
142
143inline void put(vtkDataArray* arr, vtkIdType key, const double& value)
144{
145 arr->SetTuple1(key, value);
146}
147
148// vtkAbstractArray as a property map of vtkVariants
149template <>
151{
155 typedef read_write_property_map_tag category;
156};
157
159{
160 return arr->GetVariantValue(key);
161}
162
164{
166}
167#if defined(_MSC_VER)
168namespace detail
169{
172}
173#endif
174}
175
176#include <utility> // STL Header
177
178#include <boost/config.hpp>
179#include <boost/graph/adjacency_iterator.hpp>
180#include <boost/graph/graph_traits.hpp>
181#include <boost/graph/properties.hpp>
182#include <boost/iterator/iterator_facade.hpp>
183
184// The functions and classes in this file allows the user to
185// treat a vtkDirectedGraph or vtkUndirectedGraph object
186// as a boost graph "as is".
187
188namespace boost
189{
190
192 : public iterator_facade<vtk_vertex_iterator, vtkIdType, bidirectional_traversal_tag,
193 const vtkIdType&, vtkIdType>
194{
195public:
197 : index(i)
198 {
199 }
200
201private:
202 const vtkIdType& dereference() const { return index; }
203
204 bool equal(const vtk_vertex_iterator& other) const { return index == other.index; }
205
206 void increment() { index++; }
207 void decrement() { index--; }
208
209 vtkIdType index;
210
212};
213
215 : public iterator_facade<vtk_edge_iterator, vtkEdgeType, forward_traversal_tag,
216 const vtkEdgeType&, vtkIdType>
217{
218public:
219 explicit vtk_edge_iterator(vtkGraph* g = 0, vtkIdType v = 0)
220 : directed(false)
221 , vertex(v)
222 , lastVertex(v)
223 , iter(nullptr)
224 , end(nullptr)
225 , graph(g)
226 {
227 if (graph)
228 {
229 lastVertex = graph->GetNumberOfVertices();
230 }
231
232 vtkIdType myRank = -1;
233 vtkDistributedGraphHelper* helper = this->graph ? this->graph->GetDistributedGraphHelper() : 0;
234 if (helper)
235 {
236 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
237 vertex = helper->MakeDistributedId(myRank, vertex);
238 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
239 }
240
241 if (graph != 0)
242 {
243 directed = (vtkDirectedGraph::SafeDownCast(graph) != 0);
244 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
245 {
246 ++vertex;
247 }
248
249 if (vertex < lastVertex)
250 {
251 // Get the outgoing edges of the first vertex that has outgoing
252 // edges
253 vtkIdType nedges;
254 graph->GetOutEdges(vertex, iter, nedges);
255 if (iter)
256 {
257 end = iter + nedges;
258
259 if (!directed)
260 {
261 while ( // Skip non-local edges
262 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
263 // Skip entirely-local edges where Source > Target
264 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
265 vertex > iter->Target))
266 {
267 this->inc();
268 }
269 }
270 }
271 }
272 else
273 {
274 iter = nullptr;
275 }
276 }
277
278 RecalculateEdge();
279 }
280
281private:
282 const vtkEdgeType& dereference() const
283 {
284 assert(iter);
285 return edge;
286 }
287
288 bool equal(const vtk_edge_iterator& other) const
289 {
290 return vertex == other.vertex && iter == other.iter;
291 }
292
293 void increment()
294 {
295 inc();
296 if (!directed)
297 {
298 vtkIdType myRank = -1;
300 this->graph ? this->graph->GetDistributedGraphHelper() : 0;
301 if (helper)
302 {
303 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
304 }
305
306 while (iter != 0 &&
307 ( // Skip non-local edges
308 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
309 // Skip entirely-local edges where Source > Target
310 || (((helper && myRank == helper->GetVertexOwner(iter->Target)) || !helper) &&
311 vertex > iter->Target)))
312 {
313 inc();
314 }
315 }
316 RecalculateEdge();
317 }
318
319 void inc()
320 {
321 ++iter;
322 if (iter == end)
323 {
324 // Find a vertex with nonzero out degree.
325 ++vertex;
326 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
327 {
328 ++vertex;
329 }
330
331 if (vertex < lastVertex)
332 {
333 vtkIdType nedges;
334 graph->GetOutEdges(vertex, iter, nedges);
335 end = iter + nedges;
336 }
337 else
338 {
339 iter = nullptr;
340 }
341 }
342 }
343
344 void RecalculateEdge()
345 {
346 if (iter)
347 {
348 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
349 }
350 }
351
352 bool directed;
353 vtkIdType vertex;
354 vtkIdType lastVertex;
355 const vtkOutEdgeType* iter;
356 const vtkOutEdgeType* end;
357 vtkGraph* graph;
358 vtkEdgeType edge;
359
361};
362
364 : public iterator_facade<vtk_out_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
365 const vtkEdgeType&, ptrdiff_t>
366{
367public:
368 explicit vtk_out_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
369 : vertex(v)
370 , iter(nullptr)
371 {
372 if (g)
373 {
374 vtkIdType nedges;
375 g->GetOutEdges(vertex, iter, nedges);
376 if (end)
377 {
378 iter += nedges;
379 }
380 }
381 RecalculateEdge();
382 }
383
384private:
385 const vtkEdgeType& dereference() const
386 {
387 assert(iter);
388 return edge;
389 }
390
391 bool equal(const vtk_out_edge_pointer_iterator& other) const { return iter == other.iter; }
392
393 void increment()
394 {
395 iter++;
396 RecalculateEdge();
397 }
398
399 void decrement()
400 {
401 iter--;
402 RecalculateEdge();
403 }
404
405 void RecalculateEdge()
406 {
407 if (iter)
408 {
409 edge = vtkEdgeType(vertex, iter->Target, iter->Id);
410 }
411 }
412
413 vtkIdType vertex;
414 const vtkOutEdgeType* iter;
415 vtkEdgeType edge;
416
418};
419
421 : public iterator_facade<vtk_in_edge_pointer_iterator, vtkEdgeType, bidirectional_traversal_tag,
422 const vtkEdgeType&, ptrdiff_t>
423{
424public:
425 explicit vtk_in_edge_pointer_iterator(vtkGraph* g = 0, vtkIdType v = 0, bool end = false)
426 : vertex(v)
427 , iter(nullptr)
428 {
429 if (g)
430 {
431 vtkIdType nedges;
432 g->GetInEdges(vertex, iter, nedges);
433 if (end)
434 {
435 iter += nedges;
436 }
437 }
438 RecalculateEdge();
439 }
440
441private:
442 const vtkEdgeType& dereference() const
443 {
444 assert(iter);
445 return edge;
446 }
447
448 bool equal(const vtk_in_edge_pointer_iterator& other) const { return iter == other.iter; }
449
450 void increment()
451 {
452 iter++;
453 RecalculateEdge();
454 }
455
456 void decrement()
457 {
458 iter--;
459 RecalculateEdge();
460 }
461
462 void RecalculateEdge()
463 {
464 if (iter)
465 {
466 edge = vtkEdgeType(iter->Source, vertex, iter->Id);
467 }
468 }
469
470 vtkIdType vertex;
471 const vtkInEdgeType* iter;
472 vtkEdgeType edge;
473
475};
476
477//===========================================================================
478// vtkGraph
479// VertexAndEdgeListGraphConcept
480// BidirectionalGraphConcept
481// AdjacencyGraphConcept
482
484 : public virtual bidirectional_graph_tag
485 , public virtual edge_list_graph_tag
486 , public virtual vertex_list_graph_tag
487 , public virtual adjacency_graph_tag
488{
489};
490
491template <>
492struct graph_traits<vtkGraph*>
493{
495 static vertex_descriptor null_vertex() { return -1; }
497 static edge_descriptor null_edge() { return vtkEdgeType(-1, -1, -1); }
500
503
504 typedef allow_parallel_edge_tag edge_parallel_category;
509
512};
513
514#if BOOST_VERSION >= 104500
515template <>
516struct graph_property_type<vtkGraph*>
517{
518 typedef no_property type;
519};
520#endif
521
522template <>
523struct vertex_property_type<vtkGraph*>
524{
525 typedef no_property type;
526};
527
528template <>
529struct edge_property_type<vtkGraph*>
530{
531 typedef no_property type;
532};
533
534#if BOOST_VERSION >= 104500
535template <>
536struct graph_bundle_type<vtkGraph*>
537{
538 typedef no_property type;
539};
540#endif
541
542template <>
543struct vertex_bundle_type<vtkGraph*>
544{
545 typedef no_property type;
546};
547
548template <>
549struct edge_bundle_type<vtkGraph*>
550{
551 typedef no_property type;
552};
553
554inline bool has_no_edges(vtkGraph* g)
555{
556 return ((g->GetNumberOfEdges() > 0) ? false : true);
557}
558
560{
562 {
564 }
566 {
568 }
569}
570
571//===========================================================================
572// vtkDirectedGraph
573
574template <>
576{
577 typedef directed_tag directed_category;
578};
579
580// The graph_traits for a const graph are the same as a non-const graph.
581template <>
583{
584};
585
586// The graph_traits for a const graph are the same as a non-const graph.
587template <>
589{
590};
591
592#if BOOST_VERSION >= 104500
593// Internal graph properties
594template <>
595struct graph_property_type<vtkDirectedGraph*> : graph_property_type<vtkGraph*>
596{
597};
598
599// Internal graph properties
600template <>
601struct graph_property_type<vtkDirectedGraph* const> : graph_property_type<vtkGraph*>
602{
603};
604#endif
605
606// Internal vertex properties
607template <>
609{
610};
611
612// Internal vertex properties
613template <>
614struct vertex_property_type<vtkDirectedGraph* const> : vertex_property_type<vtkGraph*>
615{
616};
617
618// Internal edge properties
619template <>
621{
622};
623
624// Internal edge properties
625template <>
626struct edge_property_type<vtkDirectedGraph* const> : edge_property_type<vtkGraph*>
627{
628};
629
630#if BOOST_VERSION >= 104500
631// Internal graph properties
632template <>
633struct graph_bundle_type<vtkDirectedGraph*> : graph_bundle_type<vtkGraph*>
634{
635};
636
637// Internal graph properties
638template <>
639struct graph_bundle_type<vtkDirectedGraph* const> : graph_bundle_type<vtkGraph*>
640{
641};
642#endif
643
644// Internal vertex properties
645template <>
647{
648};
649
650// Internal vertex properties
651template <>
652struct vertex_bundle_type<vtkDirectedGraph* const> : vertex_bundle_type<vtkGraph*>
653{
654};
655
656// Internal edge properties
657template <>
659{
660};
661
662// Internal edge properties
663template <>
664struct edge_bundle_type<vtkDirectedGraph* const> : edge_bundle_type<vtkGraph*>
665{
666};
667
668//===========================================================================
669// vtkTree
670
671template <>
673{
674};
675
676// The graph_traits for a const graph are the same as a non-const graph.
677template <>
678struct graph_traits<const vtkTree*> : graph_traits<vtkTree*>
679{
680};
681
682// The graph_traits for a const graph are the same as a non-const graph.
683template <>
684struct graph_traits<vtkTree* const> : graph_traits<vtkTree*>
685{
686};
687
688//===========================================================================
689// vtkUndirectedGraph
690template <>
692{
693 typedef undirected_tag directed_category;
694};
695
696// The graph_traits for a const graph are the same as a non-const graph.
697template <>
699{
700};
701
702// The graph_traits for a const graph are the same as a non-const graph.
703template <>
705{
706};
707
708#if BOOST_VERSION >= 104500
709// Internal graph properties
710template <>
711struct graph_property_type<vtkUndirectedGraph*> : graph_property_type<vtkGraph*>
712{
713};
714
715// Internal graph properties
716template <>
717struct graph_property_type<vtkUndirectedGraph* const> : graph_property_type<vtkGraph*>
718{
719};
720#endif
721
722// Internal vertex properties
723template <>
725{
726};
727
728// Internal vertex properties
729template <>
730struct vertex_property_type<vtkUndirectedGraph* const> : vertex_property_type<vtkGraph*>
731{
732};
733
734// Internal edge properties
735template <>
737{
738};
739
740// Internal edge properties
741template <>
742struct edge_property_type<vtkUndirectedGraph* const> : edge_property_type<vtkGraph*>
743{
744};
745
746#if BOOST_VERSION >= 104500
747// Internal graph properties
748template <>
749struct graph_bundle_type<vtkUndirectedGraph*> : graph_bundle_type<vtkGraph*>
750{
751};
752
753// Internal graph properties
754template <>
755struct graph_bundle_type<vtkUndirectedGraph* const> : graph_bundle_type<vtkGraph*>
756{
757};
758#endif
759
760// Internal vertex properties
761template <>
763{
764};
765
766// Internal vertex properties
767template <>
768struct vertex_bundle_type<vtkUndirectedGraph* const> : vertex_bundle_type<vtkGraph*>
769{
770};
771
772// Internal edge properties
773template <>
775{
776};
777
778// Internal edge properties
779template <>
780struct edge_bundle_type<vtkUndirectedGraph* const> : edge_bundle_type<vtkGraph*>
781{
782};
783
784//===========================================================================
785// vtkMutableDirectedGraph
786
787template <>
789{
790};
791
792// The graph_traits for a const graph are the same as a non-const graph.
793template <>
795{
796};
797
798// The graph_traits for a const graph are the same as a non-const graph.
799template <>
801{
802};
803
804#if BOOST_VERSION >= 104500
805// Internal graph properties
806template <>
807struct graph_property_type<vtkMutableDirectedGraph*> : graph_property_type<vtkDirectedGraph*>
808{
809};
810
811// Internal graph properties
812template <>
813struct graph_property_type<vtkMutableDirectedGraph* const> : graph_property_type<vtkDirectedGraph*>
814{
815};
816#endif
817
818// Internal vertex properties
819template <>
821{
822};
823
824// Internal vertex properties
825template <>
826struct vertex_property_type<vtkMutableDirectedGraph* const>
828{
829};
830
831// Internal edge properties
832template <>
834{
835};
836
837// Internal edge properties
838template <>
840{
841};
842
843#if BOOST_VERSION >= 104500
844// Internal graph properties
845template <>
846struct graph_bundle_type<vtkMutableDirectedGraph*> : graph_bundle_type<vtkDirectedGraph*>
847{
848};
849
850// Internal graph properties
851template <>
852struct graph_bundle_type<vtkMutableDirectedGraph* const> : graph_bundle_type<vtkDirectedGraph*>
853{
854};
855#endif
856
857// Internal vertex properties
858template <>
860{
861};
862
863// Internal vertex properties
864template <>
866{
867};
868
869// Internal edge properties
870template <>
872{
873};
874
875// Internal edge properties
876template <>
878{
879};
880
881//===========================================================================
882// vtkMutableUndirectedGraph
883
884template <>
886{
887};
888
889// The graph_traits for a const graph are the same as a non-const graph.
890template <>
892{
893};
894
895// The graph_traits for a const graph are the same as a non-const graph.
896template <>
898{
899};
900
901#if BOOST_VERSION >= 104500
902// Internal graph properties
903template <>
904struct graph_property_type<vtkMutableUndirectedGraph*> : graph_property_type<vtkUndirectedGraph*>
905{
906};
907
908// Internal graph properties
909template <>
910struct graph_property_type<vtkMutableUndirectedGraph* const>
911 : graph_property_type<vtkUndirectedGraph*>
912{
913};
914#endif
915
916// Internal vertex properties
917template <>
919{
920};
921
922// Internal vertex properties
923template <>
924struct vertex_property_type<vtkMutableUndirectedGraph* const>
926{
927};
928
929// Internal edge properties
930template <>
932{
933};
934
935// Internal edge properties
936template <>
937struct edge_property_type<vtkMutableUndirectedGraph* const>
939{
940};
941
942#if BOOST_VERSION >= 104500
943// Internal graph properties
944template <>
945struct graph_bundle_type<vtkMutableUndirectedGraph*> : graph_bundle_type<vtkUndirectedGraph*>
946{
947};
948
949// Internal graph properties
950template <>
951struct graph_bundle_type<vtkMutableUndirectedGraph* const> : graph_bundle_type<vtkUndirectedGraph*>
952{
953};
954#endif
955
956// Internal vertex properties
957template <>
959{
960};
961
962// Internal vertex properties
963template <>
964struct vertex_bundle_type<vtkMutableUndirectedGraph* const>
966{
967};
968
969// Internal edge properties
970template <>
972{
973};
974
975// Internal edge properties
976template <>
978{
979};
980
981//===========================================================================
982// API implementation
983template <>
984class vertex_property<vtkGraph*>
985{
986public:
988};
989
990template <>
991class edge_property<vtkGraph*>
992{
993public:
995};
996} // end namespace boost
997
1000{
1001 return e.Source;
1002}
1003
1006{
1007 return e.Target;
1008}
1009
1010inline std::pair<boost::graph_traits<vtkGraph*>::vertex_iterator,
1013{
1015 vtkIdType start = 0;
1017 {
1019 start = helper->MakeDistributedId(rank, start);
1020 }
1021
1022 return std::make_pair(Iter(start), Iter(start + g->GetNumberOfVertices()));
1023}
1024
1025inline std::pair<boost::graph_traits<vtkGraph*>::edge_iterator,
1028{
1030 return std::make_pair(Iter(g), Iter(g, g->GetNumberOfVertices()));
1031}
1032
1033inline std::pair<boost::graph_traits<vtkGraph*>::out_edge_iterator,
1036{
1038 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u, true));
1039 return p;
1040}
1041
1042inline std::pair<boost::graph_traits<vtkGraph*>::in_edge_iterator,
1045{
1047 std::pair<Iter, Iter> p = std::make_pair(Iter(g, u), Iter(g, u, true));
1048 return p;
1049}
1050
1051inline std::pair<boost::graph_traits<vtkGraph*>::adjacency_iterator,
1054{
1057 std::pair<OutEdgeIter, OutEdgeIter> out = out_edges(u, g);
1058 return std::make_pair(Iter(out.first, &g), Iter(out.second, &g));
1059}
1060
1062{
1063 return g->GetNumberOfVertices();
1064}
1065
1067{
1068 return g->GetNumberOfEdges();
1069}
1070
1073{
1074 return g->GetOutDegree(u);
1075}
1076
1079{
1080 return g->GetInDegree(u);
1081}
1082
1085{
1086 return g->GetDegree(u);
1087}
1088
1091{
1092 return g->AddVertex();
1093}
1094
1095inline std::pair<boost::graph_traits<vtkMutableDirectedGraph*>::edge_descriptor, bool> add_edge(
1098{
1100 return std::make_pair(e, true);
1101}
1102
1105{
1106 return g->AddVertex();
1107}
1108
1109inline std::pair<boost::graph_traits<vtkMutableUndirectedGraph*>::edge_descriptor, bool> add_edge(
1113{
1115 return std::make_pair(e, true);
1116}
1117
1118namespace boost
1119{
1120//===========================================================================
1121// An edge map for vtkGraph.
1122// This is a common input needed for algorithms.
1123
1125{
1126};
1127
1128template <>
1130{
1134 typedef readable_property_map_tag category;
1135};
1136
1139{
1140 return key.Id;
1141}
1142
1143//===========================================================================
1144// Helper for vtkGraph edge property maps
1145// Automatically converts boost edge ids to vtkGraph edge ids.
1146
1147template <typename PMap>
1149{
1150public:
1152 : pmap(m)
1153 {
1154 }
1155 PMap pmap;
1160
1161 reference operator[](const key_type& key) const { return get(pmap, key.Id); }
1162};
1163
1164template <typename PMap>
1167{
1168 return get(helper.pmap, key.Id);
1169}
1170
1171template <typename PMap>
1174{
1175 put(helper.pmap, key.Id, value);
1176}
1177
1178//===========================================================================
1179// Helper for vtkGraph vertex property maps
1180// Automatically converts boost vertex ids to vtkGraph vertex ids.
1181
1182template <typename PMap>
1184{
1185public:
1187 : pmap(m)
1188 {
1189 }
1190 PMap pmap;
1195
1196 reference operator[](const key_type& key) const { return get(pmap, key); }
1197};
1198
1199template <typename PMap>
1202{
1203 return get(helper.pmap, key);
1204}
1205
1206template <typename PMap>
1209{
1210 put(helper.pmap, key, value);
1211}
1212
1213//===========================================================================
1214// An index map for vtkGraph
1215// This is a common input needed for algorithms
1216
1218{
1219};
1220
1221template <>
1223{
1227 typedef readable_property_map_tag category;
1228};
1229
1232{
1233 return key;
1234}
1235
1236//===========================================================================
1237// Helper for vtkGraph property maps
1238// Automatically multiplies the property value by some value (default 1)
1239template <typename PMap>
1241{
1242public:
1243 vtkGraphPropertyMapMultiplier(PMap m, float multi = 1)
1244 : pmap(m)
1245 , multiplier(multi)
1246 {
1247 }
1248 PMap pmap;
1254};
1255
1256template <typename PMap>
1259{
1260 return multi.multiplier * get(multi.pmap, key);
1261}
1262
1263template <typename PMap>
1265 const typename property_traits<PMap>::key_type& key,
1267{
1268 put(multi.pmap, key, value);
1269}
1270
1271// Allow algorithms to automatically extract vtkGraphIndexMap from a
1272// VTK graph
1273template <>
1274struct property_map<vtkGraph*, vertex_index_t>
1275{
1278};
1279
1280template <>
1281struct property_map<vtkDirectedGraph*, vertex_index_t> : property_map<vtkGraph*, vertex_index_t>
1282{
1283};
1284
1285template <>
1287{
1288};
1289
1290inline vtkGraphIndexMap get(vertex_index_t, vtkGraph*)
1291{
1292 return vtkGraphIndexMap();
1293}
1294
1295template <>
1296struct property_map<vtkGraph*, edge_index_t>
1297{
1300};
1301
1302template <>
1303struct property_map<vtkDirectedGraph*, edge_index_t> : property_map<vtkGraph*, edge_index_t>
1304{
1305};
1306
1307template <>
1309{
1310};
1311
1312inline vtkGraphIndexMap get(edge_index_t, vtkGraph*)
1313{
1314 return vtkGraphIndexMap();
1315}
1316
1317// property_map specializations for const-qualified graphs
1318template <>
1319struct property_map<vtkDirectedGraph* const, vertex_index_t>
1321{
1322};
1323
1324template <>
1325struct property_map<vtkUndirectedGraph* const, vertex_index_t>
1327{
1328};
1329
1330template <>
1331struct property_map<vtkDirectedGraph* const, edge_index_t>
1333{
1334};
1335
1336template <>
1337struct property_map<vtkUndirectedGraph* const, edge_index_t>
1339{
1340};
1341} // namespace boost
1342
1343#if BOOST_VERSION > 104000
1344#include <boost/property_map/vector_property_map.hpp>
1345#else
1346#include <boost/vector_property_map.hpp>
1347#endif
1348
1349#endif // vtkBoostGraphAdapter_h
1350// 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:159
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
Base class for graph data types.
Definition: vtkGraph.h:339
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:149
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:164
An undirected graph.
A atomic type representing the union of many types.
Definition: vtkVariant.h:145
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:300
vtkIdType Source
Definition: vtkGraph.h:322
vtkIdType Target
Definition: vtkGraph.h:311
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