[vtkusers] Infovis: CSV as float & edge weights?

Jeff Baumes jeff.baumes at kitware.com
Tue Dec 2 11:05:52 EST 2008


> 1. Is there any way with vtkDelimitedTextReader to specify whether columns
> should be interpreted as strings or floats or ints -- everything is reading
> in as strings. (Or, is there a way to change the data type of the table
> columns once they are in?)

Use the vtkStringToNumeric filter after reading in the text file. It
should automatically detect and convert all integer and double arrays.

> 2. Is there a way with vtkTableToGraph, when specifying edges, to define a
> column of the table which will be interpreted as an edge "weight"? The
> adjacency matrix I'm saving from Matlab doesn't just store a binary
> connection, but a connection weight between vertices. The
> AdjacencyMatrix.cxx example uses these values as labels rather than scalars.

These values, if in a table column named "weight", will be interpreted
as the edge weight in most graph layout algorithms (Simple2D, Fast2D,
Clustering2D, and Constrained2D all have this default). Specify table
column names in the first line of the text file, and call
SetHaveHeaders(true) on the reader. The layout strategies also have a
EdgeWeightField property that you can use to change the weight array.
You can use arbitrary arrays for colors and labels also, on vertices
or edges:

  view->EdgeLabelVisibilityOn();
  view->SetEdgeLabelArrayName("label");
  view->ColorEdgesOn();
  view->SetEdgeColorArrayName("color");

Jeff



More information about the vtkusers mailing list