def connections(activities):
    """Enumerates the connections within a list of activities.

    Args:
      activities: The activities to process.  Parents/children outside these are ignored.

    Returns:
      A list of two-tuples.  Each tuple is a (parent, child) relationship.
    """
    acts = frozenset(activities)
    cons = []
    for parent in acts:
        for child in parent.children:
            if child in acts:
                cons.append((parent, child))
    return cons