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

Function main

Examples/Infovis/Cxx/ParallelBFS.cxx:22–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20#include "vtkViewTheme.h"
21
22int main(int argc, char** argv)
23{
24 MPI_Init(&argc, &argv);
25
26 vtkSmartPointer<vtkPBGLRandomGraphSource> source =
27 vtkSmartPointer<vtkPBGLRandomGraphSource>::New();
28 source->DirectedOff();
29 source->SetNumberOfVertices(100000);
30 source->SetNumberOfEdges(10000);
31 source->StartWithTreeOn();
32 vtkSmartPointer<vtkPBGLBreadthFirstSearch> bfs =
33 vtkSmartPointer<vtkPBGLBreadthFirstSearch>::New();
34 bfs->SetInputConnection(source->GetOutputPort());
35 vtkSmartPointer<vtkPBGLCollectGraph> collect = vtkSmartPointer<vtkPBGLCollectGraph>::New();
36 collect->SetInputConnection(bfs->GetOutputPort());
37
38 // Setup pipeline request
39 vtkSmartPointer<vtkMPIController> controller = vtkSmartPointer<vtkMPIController>::New();
40 controller->Initialize(&argc, &argv, 1);
41 int rank = controller->GetLocalProcessId();
42 int procs = controller->GetNumberOfProcesses();
43 collect->Update(rank, procs, 0);
44
45 if (rank == 0)
46 {
47 vtkSmartPointer<vtkUndirectedGraph> g = vtkSmartPointer<vtkUndirectedGraph>::New();
48 g->ShallowCopy(collect->GetOutput());
49 vtkSmartPointer<vtkGraphLayoutView> view = vtkSmartPointer<vtkGraphLayoutView>::New();
50 vtkSmartPointer<vtkViewTheme> theme;
51 theme.TakeReference(vtkViewTheme::CreateMellowTheme());
52 view->ApplyViewTheme(theme);
53 view->SetRepresentationFromInput(g);
54 view->SetVertexColorArrayName("BFS");
55 view->ColorVerticesOn();
56 vtkRenderWindow* win = view->GetRenderWindow();
57 view->Update();
58 view->GetRenderer()->ResetCamera();
59 win->GetInteractor()->Initialize();
60 win->GetInteractor()->Start();
61 }
62
63 controller->Finalize();
64 return 0;
65}

Callers

nothing calls this directly

Calls 15

GetNumberOfProcessesMethod · 0.80
ColorVerticesOnMethod · 0.80
NewFunction · 0.50
SetNumberOfVerticesMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45
InitializeMethod · 0.45
GetLocalProcessIdMethod · 0.45
UpdateMethod · 0.45
ShallowCopyMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected