------------------------------------------------------------------------------
| 186 | |
| 187 | //------------------------------------------------------------------------------ |
| 188 | void vtkTableToGraph::AddLinkEdge(const char* column1, const char* column2) |
| 189 | { |
| 190 | if (!column1 || !column2) |
| 191 | { |
| 192 | vtkErrorMacro("Column names may not be null."); |
| 193 | } |
| 194 | this->ValidateLinkGraph(); |
| 195 | vtkStringArray* columnArr = |
| 196 | vtkArrayDownCast<vtkStringArray>(this->LinkGraph->GetVertexData()->GetAbstractArray("column")); |
| 197 | vtkIdType source = -1; |
| 198 | vtkIdType target = -1; |
| 199 | for (vtkIdType i = 0; i < this->LinkGraph->GetNumberOfVertices(); i++) |
| 200 | { |
| 201 | if (column1 == columnArr->GetValue(i)) |
| 202 | { |
| 203 | source = i; |
| 204 | } |
| 205 | if (column2 == columnArr->GetValue(i)) |
| 206 | { |
| 207 | target = i; |
| 208 | } |
| 209 | } |
| 210 | if (source < 0) |
| 211 | { |
| 212 | this->AddLinkVertex(column1); |
| 213 | source = this->LinkGraph->GetNumberOfVertices() - 1; |
| 214 | } |
| 215 | if (target < 0) |
| 216 | { |
| 217 | this->AddLinkVertex(column2); |
| 218 | target = this->LinkGraph->GetNumberOfVertices() - 1; |
| 219 | } |
| 220 | this->LinkGraph->AddEdge(source, target); |
| 221 | this->Modified(); |
| 222 | } |
| 223 | |
| 224 | //------------------------------------------------------------------------------ |
| 225 | void vtkTableToGraph::ClearLinkEdges() |