FreeMat

- Main Page
- Related Pages

vtkMutableDirectedGraph

Section: Visualization Toolkit Filtering Classes

# Usage

vtkMutableDirectedGraph is a directed graph which has additional methods for adding edges and vertices. AddChild() is a convenience method for constructing trees. ShallowCopy(), DeepCopy(), CheckedShallowCopy() and CheckedDeepCopy() will succeed for instances of vtkDirectedGraph, vtkMutableDirectedGraph and vtkTree.

To create an instance of class vtkMutableDirectedGraph, simply invoke its constructor as follows

      obj = vtkMutableDirectedGraph

# Methods

The class vtkMutableDirectedGraph has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkMutableDirectedGraph class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkMutableDirectedGraph = obj.NewInstance ()`
- `vtkMutableDirectedGraph = obj.SafeDownCast (vtkObject o)`

- `vtkIdType = obj.AddVertex ()` - Adds a vertex to the graph and returns the index of the new vertex.

  Note: In a distributed graph (i.e. a graph whose DistributedHelper is non-null), this routine cannot be used to add a vertex if the vertices in the graph have pedigree IDs, because this routine will always add the vertex locally, which may conflict with the proper location of the vertex based on the distribution of the pedigree IDs.

- `vtkIdType = obj.AddVertex (vtkVariantArray propertyArr)` - Adds a vertex to the graph with associated properties defined in `propertyArr` and returns the index of the new vertex. The number and order of values in `propertyArr` must match up with the arrays in the vertex data retrieved by GetVertexData().

  If a vertex with the given pedigree ID already exists, its properties will be overwritten with the properties in `propertyArr` and the existing vertex index will be returned.

  Note: In a distributed graph (i.e. a graph whose DistributedHelper is non-null) the vertex added or found might not be local. In this case, AddVertex will wait until the vertex can be added or found remotely, so that the proper vertex index can be returned. If you don't actually need to use the vertex index, consider calling LazyAddVertex, which provides better performance by eliminating the delays associated with returning the vertex index.

- `obj.LazyAddVertex ()` - Adds a vertex to the graph.

  This method is lazily evaluated for distributed graphs (i.e. graphs whose DistributedHelper is non-null) the next time Synchronize is called on the helper.

- `obj.LazyAddVertex (vtkVariantArray propertyArr)` - Adds a vertex to the graph with associated properties defined in `propertyArr`. The number and order of values in `propertyArr` must match up with the arrays in the vertex data retrieved by GetVertexData().

  If a vertex with the given pedigree ID already exists, its properties will be overwritten with the properties in `propertyArr`.

  This method is lazily evaluated for distributed graphs (i.e. graphs whose DistributedHelper is non-null) the next time Synchronize is called on the helper.

- `vtkGraphEdge = obj.AddGraphEdge (vtkIdType u, vtkIdType v)` - Variant of AddEdge() that returns a heavyweight `vtkGraphEdge` object. The graph owns the reference of the edge and will replace its contents on the next call to AddGraphEdge().

  Note: This is a less efficient method for use with wrappers. In C++ you should use the faster AddEdge().

- `vtkIdType = obj.AddChild (vtkIdType parent, vtkVariantArray propertyArr)` - Convenience method for creating trees. Returns the newly created vertex id. Shortcut for

       vtkIdType v = g->AddVertex();
       g->AddEdge(parent, v);

  If non-null, `propertyArr` provides edge properties for the newly-created edge. The values in `propertyArr` must match up with the arrays in the edge data returned by GetEdgeData().
- `vtkIdType = obj.AddChild (vtkIdType parent)` - Removes the vertex from the graph along with any connected edges. Note: This invalidates the last vertex index, which is reassigned to v.
- `obj.RemoveVertex (vtkIdType v)` - Removes the vertex from the graph along with any connected edges. Note: This invalidates the last vertex index, which is reassigned to v.
- `obj.RemoveEdge (vtkIdType e)` - Removes the edge from the graph. Note: This invalidates the last edge index, which is reassigned to e.
- `obj.RemoveVertices (vtkIdTypeArray arr)` - Removes a collection of vertices from the graph along with any connected edges.
- `obj.RemoveEdges (vtkIdTypeArray arr)` - Removes a collection of edges from the graph.