RandomGraphSource
VTKEx/Python/Graphs/RandomGraphSource
Question
If you have a simple question about this example contact us at VTKExProject If your question is more complex and may require extended discussion, please use the VTK Discourse Forum
Code¶
RandomGraphSource.py
#!/usr/bin/env python
import vtk
def main():
randomGraphSource = vtk.vtkRandomGraphSource()
randomGraphSource.SetNumberOfVertices(5)
randomGraphSource.SetNumberOfEdges(4)
randomGraphSource.SetSeed(0) # This ensures repeatable results for testing. Turn this off for real use.
randomGraphSource.Update()
graphLayoutView = vtk.vtkGraphLayoutView()
graphLayoutView.AddRepresentationFromInput(randomGraphSource.GetOutput())
graphLayoutView.ResetCamera()
graphLayoutView.Render()
graphLayoutView.GetInteractor().Start()
if __name__ == '__main__':
main()