# Path: recordlinkage/types.py
# def is_pandas_2d_multiindex(x):
# 
#     return is_pandas_multiindex(x) and x.nlevels == 2
# 
# Path: recordlinkage/types.py
# def is_pandas_multiindex(x):
# 
#     return isinstance(x, (pandas.MultiIndex))


import pandas as pd
            import networkx as nx
from recordlinkage.types import is_pandas_2d_multiindex
from recordlinkage.types import is_pandas_multiindex
    """

    def __init__(self, method='greedy'):
        super(OneToOneLinking, self).__init__()

        self.method = method

    @classmethod
    def _bool_duplicated(cls, links, level):

        return links.get_level_values(level).duplicated()

    def _compute_greedy(self, links):

        result = []
        set_a = set()
        set_b = set()

        for index_a, index_b in links:
            if index_a not in set_a and index_b not in set_b:
                result.append((index_a, index_b))
                set_a.add(index_a)
                set_b.add(index_b)

        return pd.MultiIndex.from_tuples(result)

    def _compute(self, links):
        if not is_pandas_2d_multiindex(links):
            if not is_pandas_multiindex(links):
                raise TypeError("expected pandas.MultiIndex")

# Path: recordlinkage/types.py
# def is_pandas_2d_multiindex(x):
# 
#     return is_pandas_multiindex(x) and x.nlevels == 2
# 
# Path: recordlinkage/types.py
# def is_pandas_multiindex(x):
# 
#     return isinstance(x, (pandas.MultiIndex))


# Path: recordlinkage/network.py
import pandas as pd
            import networkx as nx
from recordlinkage.types import is_pandas_2d_multiindex
from recordlinkage.types import is_pandas_multiindex

    """

    def __init__(self, method='greedy'):
        super(OneToOneLinking, self).__init__()

        self.method = method

    @classmethod
    def _bool_duplicated(cls, links, level):

        return links.get_level_values(level).duplicated()

    def _compute_greedy(self, links):

        result = []
        set_a = set()
        set_b = set()

        for index_a, index_b in links:
            if index_a not in set_a and index_b not in set_b:
                result.append((index_a, index_b))
                set_a.add(index_a)
                set_b.add(index_b)

        return pd.MultiIndex.from_tuples(result)

    def _compute(self, links):
        if not is_pandas_2d_multiindex(links):
            if not is_pandas_multiindex(links):
                raise TypeError("expected pandas.MultiIndex")

            elif not is_pandas_2d_multiindex(links):