@@ -0,0 +1,2238 @@
+#!/usr/bin/env python%0Aimport vtk%0A    %0Adef main():%0A    g = vtk.vtkMutableDirectedGraph()%0A    %0A    v1 = g.AddVertex()%0A    v2 = g.AddVertex()%0A    v3 = g.AddVertex()%0A    %0A    g.AddEdge ( v1, v2 )%0A    g.AddEdge ( v2, v3 )%0A    g.AddEdge ( v3, v1 )%0A    %0A    # Do layout manually before handing graph to the view.%0A    # This allows us to know the positions of edge arrows.%0A    graphLayoutView = vtk.vtkGraphLayoutView()%0A    %0A    layout = vtk.vtkGraphLayout()%0A    strategy = vtk.vtkSimple2DLayoutStrategy()%0A    layout.SetInputData(g)%0A    layout.SetLayoutStrategy(strategy)%0A   %0A    # Tell the view to use the vertex layout we provide%0A    graphLayoutView.SetLayoutStrategyToPassThrough()%0A    # The arrows will be positioned on a straight line between two%0A    # vertices so tell the view not to draw arcs for parallel edges%0A    graphLayoutView.SetEdgeLayoutStrategyToPassThrough()%0A    %0A    # Add the graph to the view. This will render vertices and edges,%0A    # but not edge arrows.%0A    graphLayoutView.AddRepresentationFromInputConnection(layout.GetOutputPort())%0A    %0A    # Manually create an actor containing the glyphed arrows.%0A    graphToPoly = vtk.vtkGraphToPolyData()%0A    graphToPoly.SetInputConnection(layout.GetOutputPort())%0A    graphToPoly.EdgeGlyphOutputOn()%0A    %0A    # Set the position (0: edge start, 1: edge end) where%0A    # the edge arrows should go.%0A    graphToPoly.SetEdgeGlyphPosition(0.98)%0A    %0A    # Make a simple edge arrow for glyphing.%0A    arrowSource = vtk.vtkGlyphSource2D()%0A    arrowSource.SetGlyphTypeToEdgeArrow()%0A    arrowSource.SetScale(0.1)%0A    arrowSource.Update()%0A    %0A    # Use Glyph3D to repeat the glyph on all edges.%0A    arrowGlyph = vtk.vtkGlyph3D()%0A    arrowGlyph.SetInputConnection(0, graphToPoly.GetOutputPort(1))%0A    arrowGlyph.SetInputConnection(1, arrowSource.GetOutputPort())%0A    %0A    # Add the edge arrow actor to the view.%0A    arrowMapper = vtk.vtkPolyDataMapper()%0A    arrowMapper.SetInputConnection(arrowGlyph.GetOutputPort())%0A    arrowActor = vtk.vtkActor()%0A    arrowActor.SetMapper(arrowMapper)%0A    graphLayoutView.GetRenderer().AddActor(arrowActor)%0A    %0A    graphLayoutView.ResetCamera()%0A    graphLayoutView.Render()%0A    graphLayoutView.GetInteractor().Start()%0A%0Aif __name__ == '__main__':%0A    main()%0A

Create VisualizeDirectedGraph.py