[vtkusers] vtkMutableUndirectedGraph and Delete (Node and Edge) operation

Jeff Baumes jeff.baumes at kitware.com
Wed Dec 17 16:23:50 EST 2008


> In our application, I am currently creating an instance of
> vtkMutableUndirectedGraph class and display it in 3D.
> One of the functionalities we want is to delete a node (and an edge) from
> the graph. I haven't seen any functions to do this. I am new to VTK. Am I
> missing something? Do I need to implement these functions myself? (Using BGL
> or some other vtk code)

You are correct that the functionality currently does not exist to
delete vertices and edges in a graph. VTK's existing data structures
(including vtkGraph) are meant for algorithm operations where normally
one of two things is done:

1. The topology of the output is the same as the input, but the output
adds / replaces data arrays. Here a shallow copy is performed.
2. The topology of the output changes (or the output is a different
data structure entirely). In this case, the output is built "from
scratch". It is illegal to modify the input data object to a VTK
algorithm.

Neither of these cases require deletion from a data structure, so all
VTK graph algorithms (up to this point at least) may be implemented
without deletion.

For completeness (and your interactive graph-editing use case), I
think we can consider an enhancement to
vtkMutableDirected/UndirectedGraph which adds RemoveEdge,
RemoveVertex. You can file a feature request on the bug tracker, and
look into what it would take to implement that (hopefully as
efficiently as possible).

> One another question I have is if anybody tried to use vtkAssignCoordinates
> and display the graph. The coordinates of vertices are important in my graph
> and When I try to do this with AssignCoordinates (X,Y,Z coordinates), vtk
> simply ignores vertex positions.

Are you then sending it to vtkGraphLayoutView? If so, make sure to set
the layout strategy to "pass through", or it will perform a layout
algorithm on your graph and discard the original positions.

Jeff



More information about the vtkusers mailing list