def _setup_connections(self, params_dict, unknowns_dict):
        """Generate a mapping of absolute param pathname to the pathname
        of its unknown.

        Args
        ----

        params_dict : OrderedDict
            A dict of parameter metadata for the whole `Problem`.

        unknowns_dict : OrderedDict
            A dict of unknowns metadata for the whole `Problem`.

        """
        to_prom_name = self._probdata.to_prom_name

        # Get all explicit connections (stated with absolute pathnames)
        connections = self.root._get_explicit_connections()

        # get set of promoted params that are not *implicitly* connected
        # to anything, and add all implicit connections to the connections dict.
        prom_noconns = self._add_implicit_connections(connections)

        input_graph = nx.DiGraph()
        self._dangling = {}

        to_abs_pnames = self.root._sysdata.to_abs_pnames

        usrcs = set()

        # resolve any input to input connections
        for tgt, srcs in iteritems(connections):
            for src, idxs in srcs:
                input_graph.add_edge(src, tgt, idxs=idxs)
                if src in unknowns_dict:
                    usrcs.add(src)

        for prom, plist in iteritems(to_abs_pnames):
            input_graph.add_nodes_from(plist)
            if prom in prom_noconns:
                # include connections in the graph due to multiple params that
                # are promoted to the same name
                start = plist[0]
                input_graph.add_edges_from(((start,p) for p in plist[1:]),
                                           idxs=None)

        newconns = {}
        # loop over srcs that are unknowns
        for src in usrcs:
            newconns[src] = None
            src_idxs = {src:None}
            # walk depth first from each unknown src to each connected input,
            # updating src_indices if necessary
            for s, t in nx.dfs_edges(input_graph, src):
                tidxs = input_graph[s][t]['idxs']
                sidxs = src_idxs[s]

                if tidxs is None:
                    tidxs = sidxs
                elif sidxs is not None:
                    tidxs = np.array(sidxs)[tidxs]

                src_idxs[t] = tidxs

                if newconns in t:
                    newconns[t].append((src, tidxs))
                else:
                    newconns[t] = [(src, tidxs)]

        self._input_inputs = {}

        # now all nodes that are downstream of an unknown source have been
        # marked.  Anything left must be an input that is either dangling or
        # upstream of an input that does have an unknown source.
        for node in input_graph.nodes_iter():
            # only look at unmarked nodes that have 0 in_degree
            if node not in newconns and len(input_graph.pred[node]) == 0:
                nosrc = [node]
                # walk dfs from this input 'src' node until we hit a param
                # that has an unknown src
                for s, t in nx.dfs_edges(input_graph, node):
                    if t in newconns:  # found param with unknown src
                        src = newconns[t][0][0]
                        # connect the unknown src to all of the inputs connected
                        # to the current node that have no unknown src
                        for n in nosrc:
                            newconns[n] = [(src, None)]
                        break
                    else:
                        nosrc.append(t)
                else: # didn't find an unknown src, so must be dangling
                    set_nosrc = set(nosrc)
                    for n in nosrc:
                        self._dangling[to_prom_name[n]] = set_nosrc
                        self._input_inputs[n] = nosrc

        # connections must be in order across processes, so use an OrderedDict
        # and sort targets before adding them
        connections = OrderedDict()
        for tgt, srcs in sorted(newconns.items()):
            if srcs is not None:
                if len(srcs) > 1:
                    src_names = (n for n, idx in srcs)
                    self._setup_errors.append("Target '%s' is connected to "
                                              "multiple unknowns: %s" %
                                               (tgt, sorted(src_names)))
                connections[tgt] = srcs[0]

        return connections
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/core/problem.py/Problem._setup_connections/swapped operands of `in`