Skip to content
Snippets Groups Projects
Commit 381564b3 authored by Andrew Maclean's avatar Andrew Maclean
Browse files

Adding MutableGraphHelper

parent df8bba74
No related branches found
No related tags found
1 merge request!397C++ to python api 12
......@@ -424,6 +424,7 @@ This section includes ?vtkUnstructuredGrid?.
[GraphToPolyData](/PythonicAPI/Graphs/GraphToPolyData) | Convert a graph to a PolyData.
[InEdgeIterator](/PythonicAPI/Graphs/InEdgeIterator) | Iterate over edges incoming to a vertex.
[LabelVerticesAndEdges](/PythonicAPI/Graphs/LabelVerticesAndEdges) | Label vertices and edges.
[MutableGraphHelper](/PythonicAPI/InfoVis/MutableGraphHelper) | Create either a vtkMutableDirectedGraph or vtkMutableUndirectedGraph.
[RandomGraphSource](/PythonicAPI/Graphs/RandomGraphSource) | Create a random graph.
[SideBySideGraphs](/PythonicAPI/Graphs/SideBySideGraphs) | Display two graphs side by side.
[ScaleVertices](/PythonicAPI/Graphs/ScaleVertices) | Size/scale vertices based on a data array.
......
......@@ -21,7 +21,7 @@ def main():
# force_directed = vtkForceDirectedLayoutStrategy()
graph_layout_view = vtkGraphLayoutView()
graph_layout_view.AddRepresentationFromInput(random_graph_source.GetOutput())
graph_layout_view.AddRepresentationFromInput(random_graph_source.output)
# If we create a layout object directly, just set the pointer through this method.
# graph_layout_view.SetLayoutStrategy(force_directed)
graph_layout_view.SetLayoutStrategyToForceDirected()
......
#!/usr/bin/env python3
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonDataModel import vtkMutableUndirectedGraph
from vtkmodules.vtkInfovisCore import vtkMutableGraphHelper
# noinspection PyUnresolvedReferences
from vtkmodules.vtkInfovisLayout import vtkTreeLayoutStrategy
from vtkmodules.vtkViewsInfovis import vtkGraphLayoutView
def main():
colors = vtkNamedColors()
g = vtkMutableUndirectedGraph()
graph_helper = vtkMutableGraphHelper()
graph_helper.SetGraph(g)
v0 = graph_helper.AddVertex()
v1 = graph_helper.AddVertex()
graph_helper.AddEdge(v0, v1)
# Can also do this:
# graph_helper.RemoveEdge(0)
tree_layout_view = vtkGraphLayoutView()
tree_layout_view.AddRepresentationFromInput(graph_helper.graph)
# Layout only works on vtkTree if VTK::InfovisBoostGraphAlgorithms is available.
# tree_layout_view.SetLayoutStrategyToTree()
tree_layout_view.renderer.background = colors.GetColor3d('Navy')
tree_layout_view.renderer.background2 = colors.GetColor3d('MidnightBlue')
tree_layout_view.render_window.window_name = 'MutableGraphHelper'
tree_layout_view.Render()
tree_layout_view.ResetCamera()
tree_layout_view.interactor.Start()
if __name__ == '__main__':
main()
src/Testing/Baseline/PythonicAPI/InfoVis/TestMutableGraphHelper.png

130 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment