VTK
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 "vtkDirectedGraph.h"
36#include "vtkDataObject.h"
37#include "vtkDataArray.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 // VTK arrays as property maps
54 // These need to be defined before including other boost stuff
55
56 // Forward declarations are required here, so that we aren't forced
57 // to include boost/property_map.hpp.
58 template<typename> struct property_traits;
59 struct read_write_property_map_tag;
60
61#define vtkPropertyMapMacro(T, V) \
62 template <> \
63 struct property_traits<T*> \
64 { \
65 typedef V value_type; \
66 typedef V reference; \
67 typedef vtkIdType key_type; \
68 typedef read_write_property_map_tag category; \
69 }; \
70 \
71 inline property_traits<T*>::reference \
72 get( \
73 T* const & arr, \
74 property_traits<T*>::key_type key) \
75 { \
76 return arr->GetValue(key); \
77 } \
78 \
79 inline void \
80 put( \
81 T* arr, \
82 property_traits<T*>::key_type key, \
83 const property_traits<T*>::value_type & value) \
84 { \
85 arr->InsertValue(key, value); \
86 }
87
92
93 // vtkDataArray
94 template<>
96 {
97 typedef double value_type;
98 typedef double reference;
100 typedef read_write_property_map_tag category;
101 };
102
103 inline double
105 {
106 return arr->GetTuple1(key);
107 }
108
109 inline void
110 put(vtkDataArray *arr, vtkIdType key, const double& value)
111 {
112 arr->SetTuple1(key, value);
113 }
114
115 // vtkAbstractArray as a property map of vtkVariants
116 template<>
118 {
122 typedef read_write_property_map_tag category;
123 };
124
125 inline vtkVariant
127 {
128 return arr->GetVariantValue(key);
129 }
130
131 inline void
133 {
135 }
136#if defined(_MSC_VER)
137 namespace detail {
140 }
141#endif
142}
143
144#include <utility> // STL Header
145
146#include <boost/config.hpp>
147#include <boost/iterator/iterator_facade.hpp>
148#include <boost/graph/graph_traits.hpp>
149#include <boost/graph/properties.hpp>
150#include <boost/graph/adjacency_iterator.hpp>
151
152// The functions and classes in this file allows the user to
153// treat a vtkDirectedGraph or vtkUndirectedGraph object
154// as a boost graph "as is".
155
156namespace boost {
157
159 public iterator_facade<vtk_vertex_iterator,
160 vtkIdType,
161 bidirectional_traversal_tag,
162 vtkIdType,
163 vtkIdType>
164 {
165 public:
166 explicit vtk_vertex_iterator(vtkIdType i = 0) : index(i) {}
167
168 private:
169 vtkIdType dereference() const { return index; }
170
171 bool equal(const vtk_vertex_iterator& other) const
172 { return index == other.index; }
173
174 void increment() { index++; }
175 void decrement() { index--; }
176
177 vtkIdType index;
178
180 };
181
183 public iterator_facade<vtk_edge_iterator,
184 vtkEdgeType,
185 forward_traversal_tag,
186 vtkEdgeType,
187 vtkIdType>
188 {
189 public:
190 explicit vtk_edge_iterator(vtkGraph *g = 0, vtkIdType v = 0) :
191 directed(false), vertex(v), lastVertex(v), iter(0), end(0), graph(g)
192 {
193 if (graph)
194 {
195 lastVertex = graph->GetNumberOfVertices();
196 }
197
198 vtkIdType myRank = -1;
200 = this->graph? this->graph->GetDistributedGraphHelper() : 0;
201 if (helper)
202 {
203 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
204 vertex = helper->MakeDistributedId(myRank, vertex);
205 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
206 }
207
208 if (graph != 0)
209 {
210 directed = (vtkDirectedGraph::SafeDownCast(graph) != 0);
211 while (vertex < lastVertex && this->graph->GetOutDegree(vertex) == 0)
212 {
213 ++vertex;
214 }
215
216 if (vertex < lastVertex)
217 {
218 // Get the outgoing edges of the first vertex that has outgoing
219 // edges
220 vtkIdType nedges;
221 graph->GetOutEdges(vertex, iter, nedges);
222 end = iter + nedges;
223
224 if (!directed)
225 {
226 while(iter != 0
227 && (// Skip non-local edges
228 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
229 // Skip entirely-local edges where Source > Target
230 || (((helper
231 && myRank == helper->GetVertexOwner(iter->Target))
232 || !helper)
233 && vertex > iter->Target)))
234 {
235 this->inc();
236 }
237 }
238 }
239 else
240 {
241 iter = 0;
242 }
243 }
244 }
245
246 private:
247 vtkEdgeType dereference() const
248 { return vtkEdgeType(vertex, iter->Target, iter->Id); }
249
250 bool equal(const vtk_edge_iterator& other) const
251 { return vertex == other.vertex && iter == other.iter; }
252
253 void increment()
254 {
255 inc();
256 if (!directed)
257 {
258 vtkIdType myRank = -1;
260 = this->graph? this->graph->GetDistributedGraphHelper() : 0;
261 if (helper)
262 {
263 myRank = this->graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
264 }
265
266 while (iter != 0
267 && (// Skip non-local edges
268 (helper && helper->GetEdgeOwner(iter->Id) != myRank)
269 // Skip entirely-local edges where Source > Target
270 || (((helper
271 && myRank == helper->GetVertexOwner(iter->Target))
272 || !helper)
273 && vertex > iter->Target)))
274 {
275 inc();
276 }
277 }
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 = 0;
301 }
302 }
303 }
304
305 bool directed;
306 vtkIdType vertex;
307 vtkIdType lastVertex;
308 const vtkOutEdgeType * iter;
309 const vtkOutEdgeType * end;
310 vtkGraph *graph;
311
313 };
314
316 public iterator_facade<vtk_out_edge_pointer_iterator,
317 vtkEdgeType,
318 bidirectional_traversal_tag,
319 vtkEdgeType,
320 ptrdiff_t>
321 {
322 public:
323 explicit vtk_out_edge_pointer_iterator(vtkGraph *g = 0, vtkIdType v = 0, bool end = false) :
324 vertex(v)
325 {
326 if (g)
327 {
328 vtkIdType nedges;
329 g->GetOutEdges(vertex, iter, nedges);
330 if (end)
331 {
332 iter += nedges;
333 }
334 }
335 }
336
337 private:
338 vtkEdgeType dereference() const { return vtkEdgeType(vertex, iter->Target, iter->Id); }
339
340 bool equal(const vtk_out_edge_pointer_iterator& other) const
341 { return iter == other.iter; }
342
343 void increment() { iter++; }
344 void decrement() { iter--; }
345
346 vtkIdType vertex;
347 const vtkOutEdgeType *iter;
348
350 };
351
353 public iterator_facade<vtk_in_edge_pointer_iterator,
354 vtkEdgeType,
355 bidirectional_traversal_tag,
356 vtkEdgeType,
357 ptrdiff_t>
358 {
359 public:
360 explicit vtk_in_edge_pointer_iterator(vtkGraph *g = 0, vtkIdType v = 0, bool end = false) :
361 vertex(v)
362 {
363 if (g)
364 {
365 vtkIdType nedges;
366 g->GetInEdges(vertex, iter, nedges);
367 if (end)
368 {
369 iter += nedges;
370 }
371 }
372 }
373
374 private:
375 vtkEdgeType dereference() const { return vtkEdgeType(iter->Source, vertex, iter->Id); }
376
377 bool equal(const vtk_in_edge_pointer_iterator& other) const
378 { return iter == other.iter; }
379
380 void increment() { iter++; }
381 void decrement() { iter--; }
382
383 vtkIdType vertex;
384 const vtkInEdgeType *iter;
385
387 };
388
389 //===========================================================================
390 // vtkGraph
391 // VertexAndEdgeListGraphConcept
392 // BidirectionalGraphConcept
393 // AdjacencyGraphConcept
394
396 public virtual bidirectional_graph_tag,
397 public virtual edge_list_graph_tag,
398 public virtual vertex_list_graph_tag,
399 public virtual adjacency_graph_tag { };
400
401 template <>
402 struct graph_traits<vtkGraph*> {
404 static vertex_descriptor null_vertex() { return -1; }
406 static edge_descriptor null_edge() { return vtkEdgeType(-1, -1, -1); }
409
412
413 typedef allow_parallel_edge_tag edge_parallel_category;
418
419 typedef adjacency_iterator_generator<vtkGraph*,
421 };
422
423#if BOOST_VERSION >= 104500
424 template<>
425 struct graph_property_type< vtkGraph* > {
426 typedef no_property type;
427 };
428#endif
429
430 template<>
431 struct vertex_property_type< vtkGraph* > {
432 typedef no_property type;
433 };
434
435 template<>
436 struct edge_property_type< vtkGraph* > {
437 typedef no_property type;
438 };
439
440#if BOOST_VERSION >= 104500
441 template<>
442 struct graph_bundle_type< vtkGraph* > {
443 typedef no_property type;
444 };
445#endif
446
447 template<>
448 struct vertex_bundle_type< vtkGraph* > {
449 typedef no_property type;
450 };
451
452 template<>
453 struct edge_bundle_type< vtkGraph* > {
454 typedef no_property type;
455 };
456
457 inline bool has_no_edges(vtkGraph* g)
458 {
459 return ((g->GetNumberOfEdges() > 0) ? false : true);
460 }
461
463 vtkGraph* g)
464 {
466 {
468 }
470 {
472 }
473 }
474
475 //===========================================================================
476 // vtkDirectedGraph
477
478 template <>
480 {
481 typedef directed_tag directed_category;
482 };
483
484 // The graph_traits for a const graph are the same as a non-const graph.
485 template <>
486 struct graph_traits<const vtkDirectedGraph*> : graph_traits<vtkDirectedGraph*> { };
487
488 // The graph_traits for a const graph are the same as a non-const graph.
489 template <>
490 struct graph_traits<vtkDirectedGraph* const> : graph_traits<vtkDirectedGraph*> { };
491
492#if BOOST_VERSION >= 104500
493 // Internal graph properties
494 template<>
495 struct graph_property_type< vtkDirectedGraph* >
496 : graph_property_type< vtkGraph* > { };
497
498 // Internal graph properties
499 template<>
500 struct graph_property_type< vtkDirectedGraph* const >
501 : graph_property_type< vtkGraph* > { };
502#endif
503
504 // Internal vertex properties
505 template<>
506 struct vertex_property_type< vtkDirectedGraph* >
508
509 // Internal vertex properties
510 template<>
511 struct vertex_property_type< vtkDirectedGraph* const >
513
514 // Internal edge properties
515 template<>
516 struct edge_property_type< vtkDirectedGraph* >
518
519 // Internal edge properties
520 template<>
521 struct edge_property_type< vtkDirectedGraph* const >
523
524#if BOOST_VERSION >= 104500
525 // Internal graph properties
526 template<>
527 struct graph_bundle_type< vtkDirectedGraph* >
528 : graph_bundle_type< vtkGraph* > { };
529
530 // Internal graph properties
531 template<>
532 struct graph_bundle_type< vtkDirectedGraph* const >
533 : graph_bundle_type< vtkGraph* > { };
534#endif
535
536 // Internal vertex properties
537 template<>
538 struct vertex_bundle_type< vtkDirectedGraph* >
540
541 // Internal vertex properties
542 template<>
543 struct vertex_bundle_type< vtkDirectedGraph* const >
545
546 // Internal edge properties
547 template<>
548 struct edge_bundle_type< vtkDirectedGraph* >
550
551 // Internal edge properties
552 template<>
553 struct edge_bundle_type< vtkDirectedGraph* const >
555
556 //===========================================================================
557 // vtkTree
558
559 template <>
560 struct graph_traits<vtkTree*> : graph_traits<vtkDirectedGraph*> { };
561
562 // The graph_traits for a const graph are the same as a non-const graph.
563 template <>
564 struct graph_traits<const vtkTree*> : graph_traits<vtkTree*> { };
565
566 // The graph_traits for a const graph are the same as a non-const graph.
567 template <>
568 struct graph_traits<vtkTree* const> : graph_traits<vtkTree*> { };
569
570 //===========================================================================
571 // vtkUndirectedGraph
572 template <>
574 {
575 typedef undirected_tag directed_category;
576 };
577
578 // The graph_traits for a const graph are the same as a non-const graph.
579 template <>
580 struct graph_traits<const vtkUndirectedGraph*> : graph_traits<vtkUndirectedGraph*> { };
581
582 // The graph_traits for a const graph are the same as a non-const graph.
583 template <>
584 struct graph_traits<vtkUndirectedGraph* const> : graph_traits<vtkUndirectedGraph*> { };
585
586#if BOOST_VERSION >= 104500
587 // Internal graph properties
588 template<>
589 struct graph_property_type< vtkUndirectedGraph* >
590 : graph_property_type< vtkGraph* > { };
591
592 // Internal graph properties
593 template<>
594 struct graph_property_type< vtkUndirectedGraph* const >
595 : graph_property_type< vtkGraph* > { };
596#endif
597
598 // Internal vertex properties
599 template<>
600 struct vertex_property_type< vtkUndirectedGraph* >
602
603 // Internal vertex properties
604 template<>
605 struct vertex_property_type< vtkUndirectedGraph* const >
607
608 // Internal edge properties
609 template<>
610 struct edge_property_type< vtkUndirectedGraph* >
612
613 // Internal edge properties
614 template<>
615 struct edge_property_type< vtkUndirectedGraph* const >
617
618#if BOOST_VERSION >= 104500
619 // Internal graph properties
620 template<>
621 struct graph_bundle_type< vtkUndirectedGraph* >
622 : graph_bundle_type< vtkGraph* > { };
623
624 // Internal graph properties
625 template<>
626 struct graph_bundle_type< vtkUndirectedGraph* const >
627 : graph_bundle_type< vtkGraph* > { };
628#endif
629
630 // Internal vertex properties
631 template<>
632 struct vertex_bundle_type< vtkUndirectedGraph* >
634
635 // Internal vertex properties
636 template<>
637 struct vertex_bundle_type< vtkUndirectedGraph* const >
639
640 // Internal edge properties
641 template<>
642 struct edge_bundle_type< vtkUndirectedGraph* >
644
645 // Internal edge properties
646 template<>
647 struct edge_bundle_type< vtkUndirectedGraph* const >
649
650 //===========================================================================
651 // vtkMutableDirectedGraph
652
653 template <>
655
656 // The graph_traits for a const graph are the same as a non-const graph.
657 template <>
659
660 // The graph_traits for a const graph are the same as a non-const graph.
661 template <>
663
664#if BOOST_VERSION >= 104500
665 // Internal graph properties
666 template<>
667 struct graph_property_type< vtkMutableDirectedGraph* >
668 : graph_property_type< vtkDirectedGraph* > { };
669
670 // Internal graph properties
671 template<>
672 struct graph_property_type< vtkMutableDirectedGraph* const >
673 : graph_property_type< vtkDirectedGraph* > { };
674#endif
675
676 // Internal vertex properties
677 template<>
678 struct vertex_property_type< vtkMutableDirectedGraph* >
680
681 // Internal vertex properties
682 template<>
683 struct vertex_property_type< vtkMutableDirectedGraph* const >
685
686 // Internal edge properties
687 template<>
688 struct edge_property_type< vtkMutableDirectedGraph* >
690
691 // Internal edge properties
692 template<>
693 struct edge_property_type< vtkMutableDirectedGraph* const >
695
696#if BOOST_VERSION >= 104500
697 // Internal graph properties
698 template<>
699 struct graph_bundle_type< vtkMutableDirectedGraph* >
700 : graph_bundle_type< vtkDirectedGraph* > { };
701
702 // Internal graph properties
703 template<>
704 struct graph_bundle_type< vtkMutableDirectedGraph* const >
705 : graph_bundle_type< vtkDirectedGraph* > { };
706#endif
707
708 // Internal vertex properties
709 template<>
710 struct vertex_bundle_type< vtkMutableDirectedGraph* >
712
713 // Internal vertex properties
714 template<>
715 struct vertex_bundle_type< vtkMutableDirectedGraph* const >
717
718 // Internal edge properties
719 template<>
720 struct edge_bundle_type< vtkMutableDirectedGraph* >
722
723 // Internal edge properties
724 template<>
725 struct edge_bundle_type< vtkMutableDirectedGraph* const >
727
728 //===========================================================================
729 // vtkMutableUndirectedGraph
730
731 template <>
733
734 // The graph_traits for a const graph are the same as a non-const graph.
735 template <>
737
738 // The graph_traits for a const graph are the same as a non-const graph.
739 template <>
741
742#if BOOST_VERSION >= 104500
743 // Internal graph properties
744 template<>
745 struct graph_property_type< vtkMutableUndirectedGraph* >
746 : graph_property_type< vtkUndirectedGraph* > { };
747
748 // Internal graph properties
749 template<>
750 struct graph_property_type< vtkMutableUndirectedGraph* const >
751 : graph_property_type< vtkUndirectedGraph* > { };
752#endif
753
754 // Internal vertex properties
755 template<>
756 struct vertex_property_type< vtkMutableUndirectedGraph* >
758
759 // Internal vertex properties
760 template<>
761 struct vertex_property_type< vtkMutableUndirectedGraph* const >
763
764 // Internal edge properties
765 template<>
766 struct edge_property_type< vtkMutableUndirectedGraph* >
768
769 // Internal edge properties
770 template<>
771 struct edge_property_type< vtkMutableUndirectedGraph* const >
773
774#if BOOST_VERSION >= 104500
775 // Internal graph properties
776 template<>
777 struct graph_bundle_type< vtkMutableUndirectedGraph* >
778 : graph_bundle_type< vtkUndirectedGraph* > { };
779
780 // Internal graph properties
781 template<>
782 struct graph_bundle_type< vtkMutableUndirectedGraph* const >
783 : graph_bundle_type< vtkUndirectedGraph* > { };
784#endif
785
786 // Internal vertex properties
787 template<>
788 struct vertex_bundle_type< vtkMutableUndirectedGraph* >
790
791 // Internal vertex properties
792 template<>
793 struct vertex_bundle_type< vtkMutableUndirectedGraph* const >
795
796 // Internal edge properties
797 template<>
798 struct edge_bundle_type< vtkMutableUndirectedGraph* >
800
801 // Internal edge properties
802 template<>
803 struct edge_bundle_type< vtkMutableUndirectedGraph* const >
805
806 //===========================================================================
807 // API implementation
808 template <>
809 class vertex_property< vtkGraph* > {
810 public:
812 };
813
814 template <>
815 class edge_property< vtkGraph* > {
816 public:
818 };
819} // end namespace boost
820
823 vtkGraph *)
824{
825 return e.Source;
826}
827
830 vtkGraph *)
831{
832 return e.Target;
833}
834
835inline std::pair<
839{
841 vtkIdType start = 0;
843 {
844 int rank =
846 start = helper->MakeDistributedId(rank, start);
847 }
848
849 return std::make_pair( Iter(start),
850 Iter(start + g->GetNumberOfVertices()) );
851}
852
853inline std::pair<
857{
859 return std::make_pair( Iter(g), Iter(g, g->GetNumberOfVertices()) );
860}
861
862inline std::pair<
867 vtkGraph *g)
868{
870 std::pair<Iter, Iter> p = std::make_pair( Iter(g, u), Iter(g, u, true) );
871 return p;
872}
873
874inline std::pair<
879 vtkGraph *g)
880{
882 std::pair<Iter, Iter> p = std::make_pair( Iter(g, u), Iter(g, u, true) );
883 return p;
884}
885
886inline std::pair<
891 vtkGraph *g)
892{
895 std::pair<OutEdgeIter, OutEdgeIter> out = out_edges(u, g);
896 return std::make_pair( Iter(out.first, &g), Iter(out.second, &g) );
897}
898
901{
902 return g->GetNumberOfVertices();
903}
904
907{
908 return g->GetNumberOfEdges();
909}
910
914 vtkGraph *g)
915{
916 return g->GetOutDegree(u);
917}
918
923{
924 return g->GetInDegree(u);
925}
926
930 vtkGraph *g)
931{
932 return g->GetDegree(u);
933}
934
937{
938 return g->AddVertex();
939}
940
941inline std::pair<
943 bool>
948{
950 return std::make_pair(e, true);
951}
952
955{
956 return g->AddVertex();
957}
958
959inline std::pair<
961 bool>
966{
968 return std::make_pair(e, true);
969}
970
971namespace boost {
972 //===========================================================================
973 // An edge map for vtkGraph.
974 // This is a common input needed for algorithms.
975
976 struct vtkGraphEdgeMap { };
977
978 template <>
980 {
984 typedef readable_property_map_tag category;
985 };
986
989 vtkGraphEdgeMap vtkNotUsed(arr),
991 {
992 return key.Id;
993 }
994
995 //===========================================================================
996 // Helper for vtkGraph edge property maps
997 // Automatically converts boost edge ids to vtkGraph edge ids.
998
999 template<typename PMap>
1001 {
1002 public:
1004 PMap pmap;
1009 };
1010
1011 template<typename PMap>
1012 inline typename property_traits<PMap>::reference
1016 {
1017 return get(helper.pmap, key.Id);
1018 }
1019
1020 template<typename PMap>
1021 inline void
1026 {
1027 put(helper.pmap, key.Id, value);
1028 }
1029
1030 //===========================================================================
1031 // An index map for vtkGraph
1032 // This is a common input needed for algorithms
1033
1035
1036 template <>
1038 {
1042 typedef readable_property_map_tag category;
1043 };
1044
1047 vtkGraphIndexMap vtkNotUsed(arr),
1049 {
1050 return key;
1051 }
1052
1053 //===========================================================================
1054 // Helper for vtkGraph property maps
1055 // Automatically multiplies the property value by some value (default 1)
1056 template<typename PMap>
1058 {
1059 public:
1060 vtkGraphPropertyMapMultiplier(PMap m, float multi=1) : pmap(m),multiplier(multi){}
1061 PMap pmap;
1067 };
1068
1069 template<typename PMap>
1070 inline typename property_traits<PMap>::reference
1073 const typename property_traits<PMap>::key_type & key)
1074 {
1075 return multi.multiplier * get(multi.pmap, key);
1076 }
1077
1078 template<typename PMap>
1079 inline void
1082 const typename property_traits<PMap>::key_type & key,
1084 {
1085 put(multi.pmap, key, value);
1086 }
1087
1088 // Allow algorithms to automatically extract vtkGraphIndexMap from a
1089 // VTK graph
1090 template<>
1091 struct property_map<vtkGraph*, vertex_index_t>
1092 {
1095 };
1096
1097 template<>
1098 struct property_map<vtkDirectedGraph*, vertex_index_t>
1100
1101 template<>
1102 struct property_map<vtkUndirectedGraph*, vertex_index_t>
1104
1105 inline vtkGraphIndexMap get(vertex_index_t, vtkGraph*) { return vtkGraphIndexMap(); }
1106
1107 template<>
1108 struct property_map<vtkGraph*, edge_index_t>
1109 {
1112 };
1113
1114 template<>
1115 struct property_map<vtkDirectedGraph*, edge_index_t>
1117
1118 template<>
1119 struct property_map<vtkUndirectedGraph*, edge_index_t>
1121
1122 inline vtkGraphIndexMap get(edge_index_t, vtkGraph*) { return vtkGraphIndexMap(); }
1123
1124 // property_map specializations for const-qualified graphs
1125 template<>
1126 struct property_map<vtkDirectedGraph* const, vertex_index_t>
1128
1129 template<>
1130 struct property_map<vtkUndirectedGraph* const, vertex_index_t>
1132
1133 template<>
1134 struct property_map<vtkDirectedGraph* const, edge_index_t>
1136
1137 template<>
1138 struct property_map<vtkUndirectedGraph* const, edge_index_t>
1140} // namespace boost
1141
1142#if BOOST_VERSION > 104000
1143#include <boost/property_map/vector_property_map.hpp>
1144#else
1145#include <boost/vector_property_map.hpp>
1146#endif
1147
1148
1149#endif // vtkBoostGraphAdapter_h
1150// VTK-HeaderTest-Exclude: vtkBoostGraphAdapter.h
property_traits< PMap >::reference reference
property_traits< PMap >::category category
property_traits< PMap >::value_type value_type
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
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:55
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:42
Base class for graph data types.
Definition: vtkGraph.h:288
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
VTKCOMMONCORE_EXPORT int Get(vtkInformationIntegerKey *key)
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:46
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:61
An undirected graph.
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
Forward declaration required for Boost serialization.
bool has_no_edges(vtkGraph *g)
vtkPropertyMapMacro(vtkIntArray, int) vtkPropertyMapMacro(vtkIdTypeArray
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:257
@ value
Definition: vtkX3D.h:220
@ type
Definition: vtkX3D.h:516
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:255
vtkIdType Source
Definition: vtkGraph.h:273
vtkIdType Target
Definition: vtkGraph.h:264
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:287