def setupScene(self, controller, select_node=True):
        """ setupScene(controller: VistrailController) -> None
        Construct the scene to view a version tree
        
        """
        self.select_by_click = False        
        self.controller = controller

        # perform graph layout
        (tree, self.fullGraph, layout) = controller.refine_graph()

        # compute nodes that should be removed
        # O(n  * (hashmap query key time)) on 
        # where n is the number of current 
        # nodes in the scene
        removeNodeSet = set(i for i in self.versions
                            if not i in tree.vertices)

        # compute edges to be removed
        # O(n * (hashmap query key time)) 
        # where n is the number of current 
        # edges in the scene
        removeEdgeSet = set((s, t) for (s, t) in self.edges
                            if (s in removeNodeSet or
                                t in removeNodeSet or
                                not tree.has_edge(s, t)))

        # loop on the nodes of the tree
        vistrail = controller.vistrail
        am = vistrail.actionMap
        last_n = vistrail.getLastActions(controller.num_versions_always_shown)

        self.emit_selection = False
        for node in layout.nodes.itervalues():
            # version id
            v = node.id

            # version tag
            tag = tree.vertices.get(v, None)
            action = am.get(v, None)
            description = vistrail.get_description(v)

            # if the version gui object already exists...
            if v in self.versions:
                versionShape = self.versions[v]
                versionShape.setupVersion(node, action, tag, description)
            else:
                self.addVersion(node, action, tag, description)
            if select_node:
                self.versions[v].setSelected(v == controller.current_base_version)

        self.emit_selection = True
        self.selectionChanged()

        # remove gui edges from scene
        for (v1, v2) in removeEdgeSet:
            self.removeLink(v1,v2)

        # remove gui nodes from scene
        for v in removeNodeSet:
            self.removeVersion(v)

        # adjust the colors
        self.adjust_version_colors(controller)

        # Add or update links
        for source, source_tag in tree.vertices.iteritems():
            eFrom = tree.edges_from(source)
            for target, (expand, collapse) in eFrom:
                guiSource = self.versions[source]
                guiTarget = self.versions[target]
                if self.edges.has_key((source,target)):
                    linkShape = self.edges[(source,target)]
                    linkShape.setupLink(guiSource, guiTarget,
                                        expand, collapse)
                else:
                    self.addLink(guiSource, guiTarget, 
                                 expand, collapse)

        # Update bounding rects and fit to all view
        self.updateSceneBoundingRect()

        self.select_by_click = True
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/gui/version_view.py/QVersionTreeScene.setupScene/original