------------------------------------------------------------------------------
| 39 | |
| 40 | //------------------------------------------------------------------------------ |
| 41 | void 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 | //------------------------------------------------------------------------------ |
| 90 | vtkEdgeType vtkEdgeListIterator::Next() |
no test coverage detected