def __init__(self, nodes, name=None, n_samples=100):
        self.nodes = nodes
        self._inference_method = 'sumproduct'
        # We need to divine the domains for Factor nodes here...
        # First compile a mapping of factors to variables
        # from the arg spec...
        function_args = dict()
        arg_domains = dict()
        for node in self.nodes:
            if isinstance(node, VariableNode):
                #if not hasattr(node, 'domain'):
                #    node.domain = [True, False]
                arg_domains[node.name] = node.domain
            elif isinstance(node, FactorNode):
                function_args[node.func.__name__] = get_args(node.func)
        # Now if the domains for the
        # factor functions have not been explicitely
        # set we create them based on the variable
        # values it can take.
        for node in self.nodes:
            if isinstance(node, FactorNode):
                if hasattr(node.func, 'domains'):
                    continue
                domains = dict()
                for arg in get_args(node.func):
                    if not arg in arg_domains:
                        print 'WARNING: missing variable for arg:%s' % arg
                    else:
                        domains.update({arg: arg_domains[arg]})
                node.func.domains = domains
        self.name = name
        self.n_samples = n_samples
        # Now try to set the mode of inference..
        try:
            if self.has_cycles():
                # Currently only sampling
                # is supported for cyclic graphs
                self.inference_method = 'sample'
            else:
                # The sumproduct method will
                # give exact likelihoods but
                # only of the graph contains
                # no cycles.
                self.inference_method = 'sumproduct'
        except:
            print 'Failed to determine if graph has cycles, '
            'setting inference to sample.'
            self.inference_method = 'sample'
        self.enforce_minimum_samples = False
dataset/ETHPy150Open eBay/bayesian-belief-networks/bayesian/factor_graph.py/FactorGraph.__init__/original