VTK/Examples/Cxx/Graphs/ConstructGraph

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Revision as of 07:24, 14 October 2009 by Daviddoria (talk | contribs) (New page: This example shows how to construct a simple graph. <source lang="cpp"> #include <vtkMutableUndirectedGraph.h> #include <iostream> #include <string> int main(int argc, char *argv[]) { ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This example shows how to construct a simple graph.

#include <vtkMutableUndirectedGraph.h>

#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
	vtkMutableUndirectedGraph* G = vtkMutableUndirectedGraph::New();
	
	vtkIdType V1 = G->AddVertex();
	vtkIdType V2 = G->AddVertex();
	
	G->AddEdge(V1, V2);
			
    std::cout << "Number of vertices: " << G->GetNumberOfVertices() << std::endl;
    
    std::cout << "Number of edges: " << G->GetNumberOfEdges() << std::endl;
    
    //cleanup
    G->Delete();
	return 0;
}