Sets the number of nodes in the graph. The graph can only grow: this
dies if "num_nodes" is lower or equal to any of the values ever given
to AddEdge(), or lower than a previous value given to SetNumberOfNodes().
You need this if there are nodes that don't have any edges.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eDenseConnectedComponentsFinder is a class used to find connected components within a dense graph represented by integers.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to add edges (\u003ccode\u003eAddEdge\u003c/code\u003e), check connectivity between nodes (\u003ccode\u003eConnected\u003c/code\u003e), and retrieve component information.\u003c/p\u003e\n"],["\u003cp\u003eUsers can access component details such as the root nodes (\u003ccode\u003eGetComponentRoots\u003c/code\u003e), component IDs (\u003ccode\u003eGetComponentIds\u003c/code\u003e), and the number of components (\u003ccode\u003eGetNumberOfComponents\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe class supports copy and move construction for efficient object management.\u003c/p\u003e\n"],["\u003cp\u003eIt's specifically designed for dense graphs and requires setting the number of nodes explicitly if some nodes lack edges (\u003ccode\u003eSetNumberOfNodes\u003c/code\u003e).\u003c/p\u003e\n"]]],["The `DenseConnectedComponentsFinder` class in C++ identifies connected components within a graph of dense integers. Key actions include `AddEdge` to define connections between nodes and `Connected` to check if two nodes are connected. `FindRoot` retrieves the root node of a given node's set, while `GetComponentRoots` returns a list of all root nodes. Methods like `GetNumberOfComponents`, `GetNumberOfNodes`, and `GetSize` provide information about the graph. `SetNumberOfNodes` is used to define the graph's size. `GetComponentIds` returns the connected components.\n"],null,["# DenseConnectedComponentsFinder\n\nC++ Reference: class DenseConnectedComponentsFinder\n===================================================\n\n\nNote: This documentation is automatically generated.\nA connected components finder that only works on dense ints.\n\n| Method ||\n|---------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`AddEdge`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L96) | Return type: `bool ` Arguments: `int node1, int node2` The main API is the same as ConnectedComponentsFinder (below): see the homonymous functions there. |\n| [`Connected`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L97) | Return type: `bool ` Arguments: `int node1, int node2` \u003cbr /\u003e |\n| [`DenseConnectedComponentsFinder`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L83) | \u003cbr /\u003e |\n| [`DenseConnectedComponentsFinder`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L86) | \u003cbr /\u003e Arguments: `const DenseConnectedComponentsFinder&) = default; DenseConnectedComponentsFinder& operator=( const DenseConnectedComponentsFinder&` We support copy and move construction. |\n| [`DenseConnectedComponentsFinder`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L90) | \u003cbr /\u003e Arguments: `DenseConnectedComponentsFinder&&` \u003cbr /\u003e |\n| [`FindRoot`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L115) | Return type: `int ` Arguments: `int node` Returns the root of the set for the given node. node must be in \\[0;GetNumberOfNodes()-1\\]. Non-const because it does path compression internally. |\n| [`GetComponentIds`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L118) | Return type: `std::vector\u003cint\u003e ` Returns the same as GetConnectedComponents(). |\n| [`GetComponentRoots`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L104) | Return type: `const std::vector\u003cint\u003e& ` Gets the current set of root nodes in sorted order. Runs in amortized O(#components) time. |\n| [`GetNumberOfComponents`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L99) | Return type: `int ` \u003cbr /\u003e |\n| [`GetNumberOfNodes`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L100) | Return type: `int ` \u003cbr /\u003e |\n| [`GetSize`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L98) | Return type: `int ` Arguments: `int node` \u003cbr /\u003e |\n| [`SetNumberOfNodes`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/connected_components.h#L110) | Return type: `void ` Arguments: `int num_nodes` Sets the number of nodes in the graph. The graph can only grow: this dies if \"num_nodes\" is lower or equal to any of the values ever given to AddEdge(), or lower than a previous value given to SetNumberOfNodes(). You need this if there are nodes that don't have any edges. |"]]