VTK  9.4.20241202
vtkDistributedGraphHelper.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (C) 2008 The Trustees of Indiana University.
3// SPDX-License-Identifier: BSD-3-Clause AND BSL-1.0
36#ifndef vtkDistributedGraphHelper_h
37#define vtkDistributedGraphHelper_h
38
39#include "vtkCommonDataModelModule.h" // For export macro
40#include "vtkObject.h"
41
42VTK_ABI_NAMESPACE_BEGIN
43class vtkDistributedGraphHelperInternals;
44struct vtkEdgeType;
45class vtkGraph;
46class vtkVariant;
47class vtkVariantArray;
49
50// .NAME vtkVertexPedigreeIdDistributionFunction - The type of a
51// function used to determine how to distribute vertex pedigree IDs
52// across processors in a vtkGraph. The pedigree ID distribution
53// function takes the pedigree ID of the vertex and a user-supplied
54// void pointer and returns a hash value V. A vertex with that
55// pedigree ID will reside on processor V % P, where P is the number
56// of processors. This type is used in conjunction with the
57// vtkDistributedGraphHelper class.
58typedef vtkIdType (*vtkVertexPedigreeIdDistribution)(const vtkVariant& pedigreeId, void* userData);
59
60class VTKCOMMONDATAMODEL_EXPORT vtkDistributedGraphHelper : public vtkObject
61{
62public:
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
70
75
80
86
91
100
105
114 virtual void Synchronize() = 0;
115
122
124
134
135protected:
138
146 virtual void AddVertexInternal(vtkVariantArray* propertyArr, vtkIdType* vertex) = 0;
147
152 virtual void AddVertexInternal(const vtkVariant& pedigreeId, vtkIdType* vertex) = 0;
153
160 virtual void AddEdgeInternal(
161 vtkIdType u, vtkIdType v, bool directed, vtkVariantArray* propertyArr, vtkEdgeType* edge) = 0;
162
171 virtual void AddEdgeInternal(const vtkVariant& uPedigreeId, vtkIdType v, bool directed,
172 vtkVariantArray* propertyArr, vtkEdgeType* edge) = 0;
173
182 virtual void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigreeId, bool directed,
183 vtkVariantArray* propertyArr, vtkEdgeType* edge) = 0;
184
194 virtual void AddEdgeInternal(const vtkVariant& uPedigreeId, const vtkVariant& vPedigreeId,
195 bool directed, vtkVariantArray* propertyArr, vtkEdgeType* edge) = 0;
196
202 virtual vtkIdType FindVertex(const vtkVariant& pedigreeId) = 0;
203
210
215 virtual void AttachToGraph(vtkGraph* graph);
216
221
226
231
236
241
246
251
252private:
254 void operator=(const vtkDistributedGraphHelper&) = delete;
255
256 friend class vtkGraph;
257};
258
259VTK_ABI_NAMESPACE_END
260#endif // vtkDistributedGraphHelper_h
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.
virtual vtkDistributedGraphHelper * Clone()=0
Clones the distributed graph helper, returning another distributed graph helper of the same kind that...
virtual void FindEdgeSourceAndTarget(vtkIdType id, vtkIdType *source, vtkIdType *target)=0
Determine the source and target of the edge with the given 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.
virtual void AddVertexInternal(vtkVariantArray *propertyArr, vtkIdType *vertex)=0
Add a vertex, optionally with properties, to the distributed graph.
virtual void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed, vtkVariantArray *propertyArr, vtkEdgeType *edge)=0
Add an edge (u, v) to the distributed graph.
static vtkInformationIntegerKey * DISTRIBUTEDEDGEIDS()
Information Keys that distributed graphs can append to attribute arrays to flag them as containing di...
vtkIdType GetEdgeIndex(vtkIdType e_id) const
Returns local index of edge with ID e_id, by masking off top ceil(log2 P) bits of e_id.
static vtkInformationIntegerKey * DISTRIBUTEDVERTEXIDS()
Information Keys that distributed graphs can append to attribute arrays to flag them as containing di...
virtual void AddEdgeInternal(const vtkVariant &uPedigreeId, const vtkVariant &vPedigreeId, bool directed, vtkVariantArray *propertyArr, vtkEdgeType *edge)=0
Adds an edge (u, v) and returns the new edge.
virtual void AddEdgeInternal(const vtkVariant &uPedigreeId, vtkIdType v, bool directed, vtkVariantArray *propertyArr, vtkEdgeType *edge)=0
Adds an edge (u, v) and returns the new edge.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkVertexPedigreeIdDistribution VertexDistribution
The distribution function used to map a pedigree ID to a processor.
void SetVertexPedigreeIdDistribution(vtkVertexPedigreeIdDistribution Func, void *userData)
Set the pedigreeId -> processor distribution function that determines how vertices are distributed wh...
virtual void AttachToGraph(vtkGraph *graph)
Attach this distributed graph helper to the given graph.
virtual void AddVertexInternal(const vtkVariant &pedigreeId, vtkIdType *vertex)=0
Add a vertex with the given pedigreeId to the distributed graph.
vtkIdType GetVertexOwnerByPedigreeId(const vtkVariant &pedigreeId)
Determine which processor owns the vertex with the given pedigree ID.
virtual void AddEdgeInternal(vtkIdType u, const vtkVariant &vPedigreeId, bool directed, vtkVariantArray *propertyArr, vtkEdgeType *edge)=0
Adds an edge (u, v) and returns the new edge.
vtkIdType signBitMask
Bit mask to speed up decoding graph info {owner,index}.
vtkIdType GetVertexIndex(vtkIdType v) const
Returns local index of vertex v, by masking off top ceil(log2 P) bits of v.
int procBits
Number of bits required to represent # of processors (owner)
virtual vtkIdType FindVertex(const vtkVariant &pedigreeId)=0
Try to find the vertex with the given pedigree ID.
void * VertexDistributionUserData
Extra, user-specified data to be passed into the distribution function.
~vtkDistributedGraphHelper() override
vtkGraph * Graph
The graph to which this distributed graph helper is already attached.
vtkIdType highBitShiftMask
Bit mask to speed up decoding graph info {owner,index}.
int indexBits
Number of bits required to represent {vertex,edge} index.
virtual void Synchronize()=0
Synchronizes all of the processors involved in this distributed graph, so that all processors have a ...
Base class for graph data types.
Definition vtkGraph.h:340
a simple class to control print indentation
Definition vtkIndent.h:108
Key for integer values in vtkInformation.
abstract base class for most VTK objects
Definition vtkObject.h:162
An array holding vtkVariants.
A type representing the union of many types.
Definition vtkVariant.h:162
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkIdType(* vtkVertexPedigreeIdDistribution)(const vtkVariant &pedigreeId, void *userData)
int vtkIdType
Definition vtkType.h:315