I managed to actually turn it into a graph instead of the previous weird visualisation output... however it is still not a 3d graph. Apparently the layout of the graph is altered dependent on the edges you add, in the previous code i had no edges.
<br><br>All comments and remarks are still very welcome, especially on how to create a 3d graph.<br><br>Regards - Geofram<br>--- insert new code ---<br>import vtk<br>import random<br><br>points = vtk.vtkPoints()<br>for i in range(500):
<br>&nbsp;&nbsp;&nbsp; points.InsertPoint(i, random.random(),random.random(),random.random())<br><br>layout = vtk.vtkRandomLayoutStrategy()<br>layout.ThreeDimensionalLayoutOn()<br>layout.AutomaticBoundsComputationOn()<br><br>graphlayout = 
vtk.vtkGraphLayout()<br>graphlayout.SetLayoutStrategy(layout)<br><br>graph = vtk.vtkGraph()<br>graph.SetPoints(points)<br>graph.SetNumberOfVertices(500)<br><br>for i in range(499):<br>&nbsp;&nbsp;&nbsp; graph.AddEdge(i,i+1)<br><br><br>graphtopoly = 
vtk.vtkGraphToPolyData()<br>graphtopoly.SetInput(graph)<br><br>mapper = vtk.vtkPolyDataMapper()<br>mapper.SetInputConnection(graphtopoly.GetOutputPort())<br>mapper.SetInputConnection(graphlayout.GetOutputPort())<br><br>graphactor = 
vtk.vtkActor()<br>graphactor.SetMapper(mapper)<br><br>viewer = vtk.infovis.vtkGraphLayoutViewer()<br>viewer.SetInput(graph)<br><br>ren = vtk.vtkRenderer()<br>win = vtk.vtkRenderWindow()<br>win.AddRenderer(ren)<br>interact = 
vtk.vtkRenderWindowInteractor()<br>interact.SetRenderWindow(win)<br>viewer.SetRenderWindow(win)<br>win.GetInteractor().Initialize()<br>win.GetInteractor().Start()<br>---------<br><div><span class="gmail_quote">On 5/1/07, 
<b class="gmail_sendername">Geoframer</b> &lt;<a href="mailto:geoframer@gmail.com">geoframer@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey everybody,<br><br>I&#39;m relatively new to VTK but have been experimenting a bit. I&#39;m particularly interested in the graph representation which is present in the Infovis module.<br>I have been able to visualise a basic vtkRandomGraphSource (perhaps trivial to most of you) but now that i&#39;m trying to create my own (3d) graph to visualise i get some unexpected behaviour. Basically what i (am trying to) do is create 500 random points (x,y,z) with random values between 0 and 1. With these points i want to create a (3d) graph. But as there is no documentation or example code on the Infovis module yet i can&#39;t seem to get it right. The code that i have this far (heavily flawed probably but at least it produces some sort of visual result) can be found below.
<br><br>If anyone can help me or point out some of my errors in how to create and visualise graphs it would be great.<br><br>Kind regards - Geofram<br><br>------ insert python-code -----<br><span>
</span>import vtk<br>import random<br><br>points = vtk.vtkPoints()<br>for i in range(500):<br>&nbsp;&nbsp;&nbsp; points.InsertPoint(i, random.random(),random.random(),random.random())<br><br>layout = vtk.vtkRandomLayoutStrategy()<br>layout.ThreeDimensionalLayoutOn

()<br>layout.AutomaticBoundsComputationOn()<br><br>graphlayout = vtk.vtkGraphLayout()<br>graphlayout.SetLayoutStrategy(layout)<br><br>graph = vtk.vtkGraph()<br>graph.SetPoints(points)<br>graph.SetNumberOfVertices(500)<br>

graphtopoly = vtk.vtkGraphToPolyData()<br>graphtopoly.SetInput(graph)<br><br>mapper = vtk.vtkLabeledDataMapper()<br>mapper.SetInputConnection(graphtopoly.GetOutputPort())<br><br>graphactor = vtk.vtkActor2D()<br>graphactor.SetMapper

(mapper)<br><br>viewer = vtk.infovis.vtkGraphLayoutViewer()<br>viewer.SetInput(graph)<br><br>ren = vtk.vtkRenderer()<br>win = vtk.vtkRenderWindow()<br>win.AddRenderer(ren)<br>interact = vtk.vtkRenderWindowInteractor()<br>

interact.SetRenderWindow(win)<br>viewer.SetRenderWindow(win)<br>win.GetInteractor().Initialize()<br>win.GetInteractor().Start()<br>
</blockquote></div><br>