Exemple #1
0
	def __init__(self, graph, fileName):
		
		self.graph = graph
		self.fileName = fileName
		self.type = self.graph.getStringProperty('type')
		self.ids = self.graph.getStringProperty('rcmnId')
		self.weights = self.graph.getDoubleProperty('edgeWeight')
		self.substrate = 'group'
		self.catalyst = 'member'
		self.graphHandler = GraphHandler()
	def __init__(self, bipartiteGraph, substrateGraph, substrateTypeName = 'substrate', catalystTypeName = 'catalyst'):
		
		self.bipartiteGraph = bipartiteGraph
		self.superGraph = self.bipartiteGraph.getSuperGraph()
		self.substrateGraph = substrateGraph
		self.catalystGraph = None
		self.substrateTypeName = substrateTypeName
		self.catalystTypeName = catalystTypeName
		self.type = self.bipartiteGraph.getStringProperty('type')
		self.ids = self.bipartiteGraph.getStringProperty('rcmnId')
		self.weights = self.bipartiteGraph.getDoubleProperty('edgeWeight')
		self.graphHandler = GraphHandler()
    def __init__(self, analysisGraph, substrateTypeName="substrate", catalystTypeName="catalyst"):

        self.superGraph = analysisGraph
        self.bipartiteGraph = analysisGraph.addCloneSubGraph()
        self.bipartiteGraph.setName("bipartiteGraph")
        self.substrateGraph = None
        self.substrateTypeName = substrateTypeName
        self.catalystTypeName = catalystTypeName
        self.type = self.bipartiteGraph.getStringProperty("type")
        self.ids = self.bipartiteGraph.getStringProperty("rcmnId")
        self.weights = self.bipartiteGraph.getDoubleProperty("edgeWeight")

        self.graphHandler = GraphHandler()
Exemple #4
0
    def __init__(self, QWidget, consoleOutput, parent=None):
        QtGui.QWidget.__init__(self, parent)
        #Unlike better languages, you have to manually call the super constructor
        super(CaptureArea, self).__init__()

        #this is just used to print to console output
        self.consoleOut = consoleOutput

        #This is auto generated code. Notice the names
        self.gridLayout_2 = QtGui.QGridLayout(QWidget)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.captureArea = QtGui.QTabWidget(QWidget)
        self.captureArea.setObjectName(_fromUtf8("captureArea"))

        #Stores the 4 camera threads
        self.cvObjectLists = []

        #The graph handler object
        self.graphHandler = GraphHandler(self, consoleOutput)

        #Each tabs has 3 parts, they are lists so the user can make unlimited tabs
        self.tabs = []
        self.gridLayouts = []
        self.widgets = []

        self.captureArea.insertTab(3, self.graphHandler, "plot")

        #after creating all the tabs for capture area, add it to the layout. This is the whole otter layout.
        self.gridLayout_2.addWidget(self.captureArea, 0, 0, 1, 1)

        self.connect(self.gridLayout_2, QtCore.SIGNAL("resized()"),
                     self.onResize)

        self.newTab()
        self.newTab()
        self.newTab()
 def undo(self):
     if len(self.state_stack) > 1:
         self.state_stack.pop()
         try:
             self.CurrentStateSnapshot = self.state_stack[-1]
         except IndexError:
             print "no more undo-operations stored!"
         self.figure.clf()
         self.graph = self.CurrentStateSnapshot.graph
         self.selected_nodes = self.CurrentStateSnapshot.selected_nodes
         self.digraph_on = self.CurrentStateSnapshot.digraph_on
         self.normalized = self.CurrentStateSnapshot.normalized
         self.GH = GraphHandler.GraphHandler(self.figure, self.name_dict,\
                                             self.CurrentStateSnapshot)
     else:
         print "no more undo-operations stored!"
Exemple #6
0
def main():
    parser = argparse.ArgumentParser(description="run a genetic algorithm to solve the travelling salesman problem")
    req = parser.add_argument_group("required arguments")
    req.add_argument("-i", "--input_file", help="the input .tsp file", required=True)
    parser.add_argument("-o", "--output_file", help="optional output file for the bests and averages", default=None)
    parser.add_argument("-mx", "--max_gen", help="the maximum number of generations to run for (default=1000)",
                        type=int, default=1000)
    parser.add_argument("-ps", "--pop_size", help="the population size (default=50)", default=50, type=int)
    parser.add_argument("-cr", "--cross_rate", help="the crossover rate (default=1.0)", type=float, default=1.0)
    parser.add_argument("-mr", "--mut_rate", help="the mutation rate (default=0.1)", type=float, default=0.1)
    parser.add_argument("-cm", "--cross_mode", help="the mode of crossover, 0 for uox, 1 for pmx  (default=0)",
                        choices=[0, 1], type=int, default=0)
    args = parser.parse_args()

    try:
        fh = GraphHandler(args.input_file)
    except IOError as err:
        print(err)
        sys.exit(0)

    tsp = TSP(fh, args.output_file, args.max_gen, args.pop_size, args.cross_rate, args.mut_rate, args.cross_mode)
    tsp.genetic_algorithm()
class CatalystProjector:
	'''
	this class takes as input a bipartite graph
	and the associated (projected) substrate graph
	and projects it on entities of one type
	
	the class requires that:
	- nodes of the original graph have an "id" attribute (string)
	- nodes of the original graph have a two-value "type" attribute (string)
	- edges have weights (positive real numbers) stored in a 'edgeWeight' property (double)
	
	used to sort out entities, one of these value is used to compute the projected graph
	edges of the resulting graph moreover  will hold an attribute ";" concatenating id's of all
	entities f leading to edge e1 - e2 (under a property names name catalystTypeName)
	'''
	
	def __init__(self, bipartiteGraph, substrateGraph, substrateTypeName = 'substrate', catalystTypeName = 'catalyst'):
		
		self.bipartiteGraph = bipartiteGraph
		self.superGraph = self.bipartiteGraph.getSuperGraph()
		self.substrateGraph = substrateGraph
		self.catalystGraph = None
		self.substrateTypeName = substrateTypeName
		self.catalystTypeName = catalystTypeName
		self.type = self.bipartiteGraph.getStringProperty('type')
		self.ids = self.bipartiteGraph.getStringProperty('rcmnId')
		self.weights = self.bipartiteGraph.getDoubleProperty('edgeWeight')
		self.graphHandler = GraphHandler()
		
	def catalystProjection(self):
		'''
		create catalyst subgraph, insert all necessary nodes
		'''
		selected = self.bipartiteGraph.getBooleanProperty('selected')
		selected.setAllNodeValue(False)
		for n in self.bipartiteGraph.getNodes():
			if self.type[n] == self.catalystTypeName:
				selected[n] = True
		self.catalystGraph = self.superGraph.addSubGraph(selected)
		self.catalystGraph.setName(self.catalystTypeName + 'Projection')

		'''
		assign weights to catalyst nodes
		'''
		catalystIds = self.catalystGraph.getStringProperty('rcmnId')
		catalystWeights = self.catalystGraph.getDoubleProperty('edgeWeight')
		substrateIds = self.substrateGraph.getStringProperty('rcmnId')
		substrateWeights = self.substrateGraph.getDoubleProperty('edgeWeight')
		for e in self.substrateGraph.getEdges():
			catalystList = substrateIds[e].split(';')
			for id in catalystList:
				n = self.graphHandler.findNodeById(id, self.catalystGraph, catalystIds, False)
				catalystIds[n] = id
				catalystWeights[n] += substrateWeights[e]

		'''
		scan catalyst (as attributes of edges in substrate subgraph)
		and accordingly instantiate edges in catalyst subgraph
		assign weights to catalyst edges
		'''
		for e in self.substrateGraph.getEdges():
			catalystList = substrateIds[e].split(';')
			for i in range(len(catalystList)):
				for j in range(i + 1, len(catalystList)):
					n1 = self.graphHandler.findNodeById(catalystList[i], self.catalystGraph, catalystIds, False)
					n2 = self.graphHandler.findNodeById(catalystList[j], self.catalystGraph, catalystIds, False)
					f = self.graphHandler.findEdge(n1, n2, self.catalystGraph, True)
					catalystWeights[f] += substrateWeights[e]
Exemple #8
0
class CaptureArea(QtGui.QWidget):

    #This is how you pass a QWidget (MainWindow from main.py) to a class
    def __init__(self, QWidget, consoleOutput, parent=None):
        QtGui.QWidget.__init__(self, parent)
        #Unlike better languages, you have to manually call the super constructor
        super(CaptureArea, self).__init__()

        #this is just used to print to console output
        self.consoleOut = consoleOutput

        #This is auto generated code. Notice the names
        self.gridLayout_2 = QtGui.QGridLayout(QWidget)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.captureArea = QtGui.QTabWidget(QWidget)
        self.captureArea.setObjectName(_fromUtf8("captureArea"))

        #Stores the 4 camera threads
        self.cvObjectLists = []

        #The graph handler object
        self.graphHandler = GraphHandler(self, consoleOutput)

        #Each tabs has 3 parts, they are lists so the user can make unlimited tabs
        self.tabs = []
        self.gridLayouts = []
        self.widgets = []

        self.captureArea.insertTab(3, self.graphHandler, "plot")

        #after creating all the tabs for capture area, add it to the layout. This is the whole otter layout.
        self.gridLayout_2.addWidget(self.captureArea, 0, 0, 1, 1)

        self.connect(self.gridLayout_2, QtCore.SIGNAL("resized()"),
                     self.onResize)

        self.newTab()
        self.newTab()
        self.newTab()

    def resizeEvent(self, evt=None):
        print("HEYT \n")
        self.emit(QtCore.SIGNAL("resize()"))
        print("HEYT \n")

    def newTab(self):
        self.tabs.append(QtGui.QWidget())
        tabObjectName = "tab" + str(len(self.tabs) - 1)
        self.tabs[(len(self.tabs) - 1)].setObjectName(_fromUtf8(tabObjectName))

        self.gridLayouts.append(
            QtGui.QGridLayout(self.tabs[len(self.tabs) - 1]))
        gridLayoutObjectName = "gridLayout" + str(len(self.gridLayouts) - 1)
        self.gridLayouts[len(self.gridLayouts) - 1].setObjectName(
            _fromUtf8(gridLayoutObjectName))

        self.widgets.append(QtGui.QWidget(self.tabs[len(self.tabs) - 1]))
        widgetObjectName = "widget" + str(len(self.widgets) - 1)
        self.widgets[len(self.widgets) - 1].setObjectName(
            _fromUtf8(widgetObjectName))

        self.gridLayouts[len(self.gridLayouts) - 1].addWidget(
            self.widgets[len(self.widgets) - 1], 0, 0, 1, 1)
        self.captureArea.addTab(self.tabs[len(self.tabs) - 1], _fromUtf8(""))

        #this sets the last tab is the current tab
        #self.captureArea.setCurrentWidget(self.tabs[(len(self.tabs) - 1)])

    def removeTab(self, index):
        widget = self.captureArea.widget(index)
        if widget is not None:
            widget.deleteLater()
        self.captureArea.removeTab(index)

    def start_clicked(self):
        lastWidget = self.getWidget()
        self.cvHandler3 = CVHandler(self.widgets[lastWidget],
                                    "tcp://192.168.2.6:9092",
                                    self.graphHandler)
        self.cvHandler3.start_clicked()

    def connectToCameras(self):
        print("TEST")
        self.captureArea.setCurrentWidget(self.tabs[0])

        lastWidget = self.getWidget()

        try:
            cvHandler = CVHandler(self.widgets[lastWidget],
                                  "tcp://192.168.1.100:9092", 100,
                                  self.graphHandler)
            self.cvObjectLists.append(cvHandler)
            self.newTab()
            # self.cvHandler2 = CVHandler(self.widgets[1], "tcp://192.168.2.201:9092", self.graphHandler)
            # self.cvHandler2.start_clicked()
            # self.consoleOut.outputText("Playing video from webcam")
        except:
            self.consoleOut.outputText(
                "Error has occurred while connecting to 192.168.1.100")

        try:
            #cvHandler = CVHandler(self.widgets[lastWidget], "tcp://192.168.1.101:9092", 101, self.graphHandler)
            #self.cvObjectLists.append(cvHandler)
            self.newTab()
            # self.cvHandler2 = CVHandler(self.widgets[1], "tcp://192.168.2.201:9092", self.graphHandler)
            # self.cvHandler2.start_clicked()
            # self.consoleOut.outputText("Playing video from webcam")
        except:
            self.consoleOut.outputText(
                "Error has occurred while connecting to 192.168.1.101")

        lastWidget = self.getWidget()

        try:
            #cvHandler = CVHandler(self.widgets[lastWidget], "tcp://192.168.1.102:9092", 102, self.graphHandler)
            #self.cvObjectLists.append(cvHandler)
            self.newTab()
            # self.cvHandler2 = CVHandler(self.widgets[1], "tcp://192.168.2.201:9092", self.graphHandler)
            # self.cvHandler2.start_clicked()
            # self.consoleOut.outputText("Playing video from webcam")
        except:
            self.consoleOut.outputText(
                "Error has occurred while connecting to 192.168.1.102")

        lastWidget = self.getWidget()

        try:
            cvHandler = CVHandler(self.widgets[lastWidget],
                                  "tcp://192.168.1.103:9092", 103,
                                  self.graphHandler)
            #self.cvObjectLists.append(cvHandler)
            #self.newTab()
            # self.cvHandler2 = CVHandler(self.widgets[1], "tcp://192.168.2.201:9092", self.graphHandler)
            # self.cvHandler2.start_clicked()
            # self.consoleOut.outputText("Playing video from webcam")
        except:
            self.consoleOut.outputText(
                "Error has occurred while connecting to 192.168.1.103")

        lastWidget = self.getWidget()

        for cv in self.cvObjectLists:
            cv.start_clicked()

    def deleteThisLater(self):
        self.graphHandler.testtest()

    def recordMotion(self):
        #self.cvHandler2.recordMotion()
        if (len(self.cvObjectLists) > 0):
            for cv in self.cvObjectLists:
                cv.recordMotion()
        else:
            self.consoleOut.outputText("No cameras connected")

    def stopRecording(self):
        if (len(self.cvObjectLists) > 0):
            for cv in self.cvObjectLists:
                cv.stopRecording()
        else:
            self.consoleOut.outputText("No cameras connected")

    def takeCalibrationPicture(self):
        if (len(self.cvObjectLists) > 0):
            for cv in self.cvObjectLists:
                self.consoleOut.outputText("Taking Pictures")
                cv.takeCalibrationPic()
        else:
            self.consoleOut.outputText("No cameras connected")

    def stop_playback(self):
        try:
            self.cvHandler2.stop_playback()
            self.consoleOut.outputText("Video has stopped")
        except:
            self.consoleOut.outputText("No camera connected at this time")

    def playBackMotion(self):
        self.graphHandler.playbackMotion()

    def connectToIP(self, ipAddress, test):
        self.newTab()
        test.connectToStream(self)

    def getWidget(self):
        #CaptureArea.newTab()
        #lastTab = len(self.tabs) - 1
        lastWidget = len(self.widgets) - 1
        return int(lastWidget)

    def getGraph(self):
        return self.graphHandler

    def openVideoFile(self, fileName):
        pass

    def openMaskingDebugWindow(self):
        self.debugWin = MaskingDebug()

    def onResize(self):
        self.window_width = self.widgets[0].frameSize().width()
        self.window_height = self.widgets[0].frameSize().height()
        self.openGLHandler.updateWindowSize(self.window_width,
                                            self.window_height)

    def getWindowHeight(self):
        return self.window_height

    def getWindowWidth(self):
        return self.window_width

    def updateWindowSize(self):
        #print("wht the f**k")
        self.window_width = self.captureArea.frameSize().width()
        self.window_height = self.captureArea.frameSize().height()

    #this is going to check if the camera is recording, because there are 6 cam, we need an int
    def isRunning(self, cam=0):
        #self.cvHandler2[0].isRunning()
        return self.cvHandler2.isRunning()

    def updatePoints(self):
        self.cvHandler2.setPoints()
        print("test")

    '''
class SubstrateProjector:
    """
	this class takes as input a bipartite graph
	(typically obtained using a loader class, see KublaiLoader for example)
	and projects it on entities of one type
	projected paths e1 - f - e2 induce edges e1 - e2
	weights on edges e1 - f, f - e2 combine and define
	weights on edges e1 - e2
	
	the class requires that:
	- nodes of the original graph have an "id" attribute (string)
	- nodes of the original graph have a two-value "type" attribute (string)
	- edges have weights (positive real numbers) stored in a 'edgeWeight' property (double)
	
	used to sort out entities, one of these value is used to compute the projected graph
	edges of the resulting graph moreover  will hold an attribute ";" concatenating id's of all
	entities f leading to edge e1 - e2 (under a property names name catalystTypeName)
	
	caution: the graph should have been obtained form whatever convenient loader class
	and then needs to be cloned -- the code should operate on the clone graph (new
	entities will be added to he original graph)
	"""

    def __init__(self, analysisGraph, substrateTypeName="substrate", catalystTypeName="catalyst"):

        self.superGraph = analysisGraph
        self.bipartiteGraph = analysisGraph.addCloneSubGraph()
        self.bipartiteGraph.setName("bipartiteGraph")
        self.substrateGraph = None
        self.substrateTypeName = substrateTypeName
        self.catalystTypeName = catalystTypeName
        self.type = self.bipartiteGraph.getStringProperty("type")
        self.ids = self.bipartiteGraph.getStringProperty("rcmnId")
        self.weights = self.bipartiteGraph.getDoubleProperty("edgeWeight")

        self.graphHandler = GraphHandler()

    def substrateProjection(self):
        selected = self.bipartiteGraph.getBooleanProperty("selected")
        selected.setAllNodeValue(False)
        for n in self.bipartiteGraph.getNodes():
            if self.type[n] == self.substrateTypeName:
                selected[n] = True
        self.substrateGraph = self.superGraph.addSubGraph(selected)
        self.substrateGraph.setName(self.substrateTypeName + "Projection")

        weights = self.substrateGraph.getDoubleProperty("edgeWeight")
        catalystIds = self.substrateGraph.getStringProperty("rcmnId")
        for s1 in self.substrateGraph.getNodes():
            for s2 in self.substrateGraph.getNodes():
                if (not s1.id == s2.id) and (self.graphHandler.findEdge(s1, s2, self.substrateGraph, False) == None):
                    catalystSet = self.graphHandler.commonNeighbors(s1, s2, self.bipartiteGraph)
                    if len(catalystSet) > 0:
                        e = self.substrateGraph.addEdge(s1, s2)
                        catalystIds.setEdgeValue(e, self.__catalystListValue__(catalystSet))
                        weights[e] = self.__scalarProduct__(s1, s2, catalystSet)

    def __scalarProduct__(self, s1, s2, catalystSet):
        prod = 0.0
        for c in catalystSet:
            e1 = self.graphHandler.findEdge(c, s1, self.bipartiteGraph, False)
            e2 = self.graphHandler.findEdge(c, s2, self.bipartiteGraph, False)
            prod += self.weights[e1] * self.weights[e2]
        return prod

    def __catalystListValue__(self, catalystSet):
        cIds = []
        for c in catalystSet:
            cIds.append(self.ids.getNodeValue(c))
        return ";".join(cIds)
Exemple #10
0
class KublaiLoader:
	
	def __init__(self, graph, fileName):
		
		self.graph = graph
		self.fileName = fileName
		self.type = self.graph.getStringProperty('type')
		self.ids = self.graph.getStringProperty('rcmnId')
		self.weights = self.graph.getDoubleProperty('edgeWeight')
		self.substrate = 'group'
		self.catalyst = 'member'
		self.graphHandler = GraphHandler()
						
	def processFile(self):
		'''
		builds a bipartite graph with edges connecting substrates (documents/grups)
		to catalysts (terms/members) -- substrates interact through catalysts
		
		todo/wishlist: would need to process time data as well (post dates)
		'''
		self.graph.clear()
		
		f = open(self.fileName, "r")
		obj = json.loads(f.read())
		topics = [t for t in obj]
		
		for t in topics:
			self.__processTopic__(t)
		
		mh = MetricHandler(self.graph)
		mh.rescale(self.weights, [1.0, 10.0], 'edges')
		
	def __processTopic__(self, topic):
		idContributor = topic["contributorName"].encode('UTF-8')
		if "groupId" not in topic.keys():
			return None
		idGroup = topic["groupId"].encode('UTF-8')
		content = topic["description"].encode('UTF-8')
		
		nContrib = self.graphHandler.findNodeById(idContributor, self.graph, self.ids, True)
		nGroup = self.graphHandler.findNodeById(idGroup, self.graph, self.ids, True)
		e = self.graphHandler.findEdge(nContrib, nGroup, self.graph)
		self.weights[e] += len(content)			
				
		if "comments" in topic.keys():
			for c in topic["comments"]:
				if self.__processComment__(c, idGroup, nGroup) == None:
					print c
			
	def __processComment__(self, comment, idGroup, nodeGroup):
		idContributor = comment["contributorName"].encode('UTF-8')
		if comment["description"] == None:
			print idGroup
			print idContributor
			return None
		content = comment["description"].encode('UTF-8')

		nContrib = self.graphHandler.findNodeById(idContributor, self.graph, self.ids, True)
		e = self.graphHandler.findEdge(nContrib, nodeGroup, self.graph, True)
		self.weights[e] += len(content)
		return True	
Exemple #11
0
n2 = GS.Node(0, 9, 1)  #B
n3 = GS.Node(10, 0, 1)  #C
n4 = GS.Node(10, 10, 1)  #D

# These should never be here and are only for debug purpose

e1 = GS.Edge(n1, n2)  #AB
e2 = GS.Edge(n1, n3)  #AC
e3 = GS.Edge(n2, n4)  #BD
e4 = GS.Edge(n3, n4)  #CD
e5 = GS.Edge(n1, n4)

start_nodes = [n1, n2, n3, n4]
start_edges = []  #[e1, e2, e3, e4, e5]

GH = gh.GraphHandler()

for node in start_nodes:
    GH.addNode(node)

for edge in start_edges:
    GH.addEdgeObj(edge)

valueX = ''
valueY = ''

while valueX != 'exit' or valueY != 'exit':
    valueX = float(input("Value X of new node: "))
    valueY = float(input("Value Y of new node: "))
    if isinstance(valueX,
                  (int, long, float)) and isinstance(valueY,
Exemple #12
0
import GraphHandler as g
import MessageHandler as m

exit = False
baudrate = 15500
timeout = None
port_name = "COM4"
Gui = g.GraphHandler()
MsgHandler = m.MessageHandler(port_name, baudrate_=baudrate, timeout_=timeout)
MsgHandler.StartCommunication()
while (not Gui.exit):
    for i in range(3 * g.NUMBER_OF_KINETIS):
        msg = MsgHandler.ReadFrame()
        MsgHandler.ManageMessage(msg, len(msg))
    list_of_positions = MsgHandler.GetPositions()
    Gui.UpdateBoards(list_of_positions)

MsgHandler.EndCommunication()
Exemple #13
0
                        type=int,
                        help='set multicast port')
    parser.add_argument('-ip',
                        '--set_stream_ip',
                        action='store',
                        default='224.2.10.100',
                        help='set multicast ip address group')

    # for testing purposes
    parser.add_argument(
        '-om',
        '--set_output_mode',
        action='store',
        default='print',
        choices=['print', 'store', 'graph'],
        help=
        'set multicast output mode, print to terminal, store to file, or graph (requires ui) (default="print")'
    )

    args = parser.parse_args()

    mcast = multicast(args.set_stream_ip, args.set_stream_port,
                      args.set_stream_type, args.set_output_mode)

    if args.set_output_mode in ['store', 'print']:
        mcast.output()
    else:
        tsg = gh.GraphHandler(mcast.generator())

        # tsg = gh.TimeSeriesGraph(stream().read())
    def __init__(self, source_path, dest_path):
        self.state_stack = []  #stores snapshots of current states
        self.max_stored_states = 10  #defines the maximum number of possible undo actions

        work_name = os.path.basename(
            source_path)  #name of the directory we are working in
        self.source_path = source_path  #path to the working directory
        if dest_path == None:
            dest_path = source_path  #if specified: path to the directory files will be saved to

        self.name_dict = {
            'work_name':
            work_name,  #store names in dictionary to make things cleaner
            'source_path': source_path,
            'dest_path': dest_path
        }

        self.graph = None  #try to load the graph object
        for f in os.listdir(self.name_dict['source_path']
                            ):  #look for a file that ends with '_red1.gpickle'
            if f.endswith(
                    '_red1.gpickle'
            ):  #this corresponds to a graph which has some redundant nodes left
                self.graph = load(join(self.name_dict['source_path'], f))
        if self.graph == None:  #if no suitable file is found, print an error message
            print 'No corresponding .gpickle-file found!'\
            +' (looking for _red1.gpickle)\nClosing the GUI.'
            printHelp()  #print the help message and exit the GUI
            sys.exit()

        self.selected_nodes = {
        }  #stores the keys of the currently selected nodes
        self.mode_list = [
        ]  #list of currently switched on modes which will be displayed at the top of the figure

        #state flags
        self.select_on = False  #node selection mode on?
        self.digraph_on = False  #is the graph already a digraph?
        self.normalized = False  #has the graph already been streamlined? (redundant nodes removed)
        self.shift_on = False  #is the shift key pressed? (ugly but working modifier handling...)

        #figure initialization
        self.dpi = 100  #resolution, increase for super crowded graphs
        self.figsize = (
            12, 12
        )  #size of the figure, tinker with this if the displayed figure does not fit your monitor
        self.figure = plt.figure(dpi=self.dpi, figsize=self.figsize)

        #initialize state stack and mode
        self.CurrentStateSnapshot = StateSnapshot(
            self.graph,  #take an initial snapshot and store it
            self.selected_nodes,
            self.digraph_on,
            self.normalized)
        self.update_state_stack()

        self.GH = GraphHandler.GraphHandler(
            self.figure,
            self.name_dict,  #initialize the graph handler
            self.CurrentStateSnapshot)

        self.update_mode("Image: " + self.name_dict['work_name'],
                         'add')  #update the display at the top of the figure
        self.edit_loop()  #start the main interaction loop