MCPcopy Create free account
hub / github.com/Kitware/VTK / GenerateVTKGraph

Function GenerateVTKGraph

Utilities/Maintenance/VisualizeModuleDependencies.py:211–237  ·  view source on GitHub ↗

Take the vertices and edge list in the graph parameter and return a VTK graph.

(graph)

Source from the content-addressed store, hash-verified

209 return graph
210
211def GenerateVTKGraph(graph):
212 '''
213 Take the vertices and edge list in the graph parameter
214 and return a VTK graph.
215 '''
216 g = vtkMutableDirectedGraph()
217 # Label the vertices
218 labels = vtkStringArray()
219 labels.SetNumberOfComponents(1)
220 labels.SetName("Labels")
221
222 index = dict()
223 l = list(graph[0])
224 # Make the vertex labels and create a dictionary with the
225 # keys as labels and the vertex ids as the values.
226 for i in range(0, len(l)):
227 # Set the vertex labels
228 labels.InsertNextValue(l[i])
229 index[l[i]] = g.AddVertex()
230 g.GetVertexData().AddArray(labels)
231 # Add edges
232 l = list(graph[1])
233 for i in range(0, len(l)):
234 ll = list(l[i])
235 g.AddGraphEdge(index[ll[0]], index[ll[1]])
236# g.Dump()
237 return g
238
239def DisplayGraph(graph):
240 '''

Callers 1

mainFunction · 0.85

Calls 11

GetVertexDataMethod · 0.80
vtkStringArrayClass · 0.50
listClass · 0.50
rangeClass · 0.50
SetNumberOfComponentsMethod · 0.45
SetNameMethod · 0.45
InsertNextValueMethod · 0.45
AddVertexMethod · 0.45
AddArrayMethod · 0.45
AddGraphEdgeMethod · 0.45

Tested by

no test coverage detected