| Function connectedComponents Decomposes an undirected graph into its connected components. connectedComponents(g, components) Include Headers seqan/graph_algorithms.h Parameters
g | In-parameter:An undirected graph. Types: Undirected Graph
components | Out-parameter:A property map. Remarks: Each vertex is mapped to a component id. If two vertices share the same id they are in the same component.
Return Values The number of components. Examples A simple example on how to use this function. The output now is: // Build Input. Graph<Undirected<> > graph; for (unsigned i = 0; i < 5; ++i) addVertex(graph); addEdge(graph, 0, 1); addEdge(graph, 0, 3); addEdge(graph, 2, 4); String<unsigned> components; unsigned numComponents = 0; // Call Algorithm. numComponents = connectedComponents(g, components); // Print Result. std::cout << "Number of components: " << numComponents << std::endl; std::cout << std::endl << "Vertex -> Component" << std::endl; for (unsigned i = 0; i < length(components); ++i) std::cout << i << " -> " << components[i] << std::endl; Number of components: 2 Vertex -> Component 0 -> 0 1 -> 0 2 -> 1 3 -> 0 4 -> 1 SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:58