[vtkusers] Infovis: Use calculator on graphs?
Eric E. Monson
emonson at cs.duke.edu
Wed Dec 3 09:52:15 EST 2008
Hey,
I've been having trouble using the vtkArrayCalculator on a
vtkUndirectedGraph. From the options (like UseVertexData) it looks
like it should work, but I can't tell if there's a problem or if I'm
just doing something wrong.
Here's my test code that starts like Examples/Infovis/Python/
boost_centrality.py -- can anyone see something silly I'm doing? (CVS
VTK, OS X 10.5.5, Python 2.5)
# ===================
import vtk
source = vtk.vtkRandomGraphSource()
source.DirectedOff()
source.SetNumberOfVertices(50)
source.SetEdgeProbability(0.01)
source.SetUseEdgeProbability(True)
source.AllowParallelEdgesOn()
source.AllowSelfLoopsOn()
source.SetStartWithTree(True)
# Connect to the Boost centrality filter.
centrality = vtk.vtkBoostBrandesCentrality ()
centrality.SetInputConnection(source.GetOutputPort())
centrality.Update()
centrality
.GetOutputDataObject(0).GetVertexData().SetActiveScalars('centrality')
# Rescale the graph vertex scalars
calc = vtk.vtkArrayCalculator()
calc.SetInputConnection(centrality.GetOutputPort())
calc.SetAttributeModeToUseVertexData()
calc.AddScalarArrayName("centrality", 0)
calc.SetFunction("centrality / 100.0")
calc.SetResultArrayName("centScaled")
calc.Update()
# =================
Thanks,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
More information about the vtkusers
mailing list