MCPcopy Create free account
hub / github.com/Kitware/VTK / SetGraph

Method SetGraph

Common/DataModel/vtkEdgeListIterator.cxx:41–87  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

39
40//------------------------------------------------------------------------------
41void vtkEdgeListIterator::SetGraph(vtkGraph* graph)
42{
43 vtkSetObjectBodyMacro(Graph, vtkGraph, graph);
44 this->Current = nullptr;
45 this->End = nullptr;
46 if (this->Graph && this->Graph->GetNumberOfEdges() > 0)
47 {
48 this->Directed = (vtkDirectedGraph::SafeDownCast(this->Graph) != nullptr);
49 this->Vertex = 0;
50 vtkIdType lastVertex = this->Graph->GetNumberOfVertices();
51
52 int myRank = -1;
53 vtkDistributedGraphHelper* helper = this->Graph->GetDistributedGraphHelper();
54 if (helper)
55 {
56 myRank = this->Graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
57 this->Vertex = helper->MakeDistributedId(myRank, this->Vertex);
58 lastVertex = helper->MakeDistributedId(myRank, lastVertex);
59 }
60
61 // Find a vertex with nonzero out degree.
62 while (this->Vertex < lastVertex && this->Graph->GetOutDegree(this->Vertex) == 0)
63 {
64 ++this->Vertex;
65 }
66 if (this->Vertex < lastVertex)
67 {
68 vtkIdType nedges;
69 this->Graph->GetOutEdges(this->Vertex, this->Current, nedges);
70 this->End = this->Current + nedges;
71 // If it is undirected, skip edges that are non-local or
72 // entirely-local edges whose source is greater than the target.
73 if (!this->Directed)
74 {
75 while (this->Current != nullptr &&
76 ( // Skip non-local edges.
77 (helper && helper->GetEdgeOwner(this->Current->Id) != myRank)
78 // Skip entirely-local edges where Source > Target
79 || (((helper && myRank == helper->GetVertexOwner(this->Current->Target)) || !helper) &&
80 this->Vertex > this->Current->Target)))
81 {
82 this->Increment();
83 }
84 }
85 }
86 }
87}
88
89//------------------------------------------------------------------------------
90vtkEdgeType vtkEdgeListIterator::Next()

Callers 5

InitializeMethod · 0.45
InitializeMethod · 0.45
InitializeMethod · 0.45
GetEdgesMethod · 0.45
GetVerticesMethod · 0.45

Calls 11

IncrementMethod · 0.95
GetNumberOfVerticesMethod · 0.80
MakeDistributedIdMethod · 0.80
GetOutDegreeMethod · 0.80
GetOutEdgesMethod · 0.80
GetEdgeOwnerMethod · 0.80
GetVertexOwnerMethod · 0.80
GetNumberOfEdgesMethod · 0.45
GetMethod · 0.45
GetInformationMethod · 0.45

Tested by

no test coverage detected