<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def compute(self, links):
 """Return the connected components. Parameters links : pandas.MultiIndex The links to apply one-to-one matching on. Returns ------- list of pandas.MultiIndex A list with pandas.MultiIndex objects. Each MultiIndex object represents a set of connected record pairs. """


        try:
            import networkx as nx
        except ImportError():
            raise Exception("'networkx' module is needed for this operation")

        G = nx.Graph()
        G.add_edges_from(links.values)
        connected_components = nx.connected_component_subgraphs(G)

        links_result = [pd.MultiIndex.from_tuples(subgraph.edges())
                        for subgraph in connected_components]

        return links_result