def parse(self, path): fobj = open(path, "r") graph = HarrisGraph() graph.node_attr['shape'] = 'box' groups = dict() # Knoten hinzufuegen, Gruppen erzeugen for line in fobj: line = line.strip() stratum = line.split(";") if stratum[1] == "context": graph.add_node(stratum[0], stratum[1]) #graph.add_node(stratum[0], stratum[1], stratum[2], stratum[3], stratum[4]) # if stratum[1] == "group": # groups[stratum[0]] = set() # Kanten hinzufuegen, Knoten zu Gruppen zuordnen fobj.close() fobj = open(path, "r") index = 0 for line in fobj: line = line.strip() stratum = line.split(";") unitname = stratum[0] later = set(stratum[2].split(", ")) if stratum[1] == "context": for node in later: if node != "": graph.add_edge(unitname, node, "later") earlier = set(stratum[3].split(", ")) for node in earlier: if node != "": graph.add_edge(node, unitname, "earlier") # group = set(stratum[8].split(", ")) # for g in group: # if g in groups: # groups[g].add(unitname) # equal = set(stratum[7].split(", ")) # for node in equal: # if node != "": # graph.add_edge(unitname, node, "concurrent") # partof = set(stratum[8].split(", ")) # for node in partof: # if node != "": # graph.add_edge(unitname, node, "concurrent") fobj.close() # for key in groups: # graph.add_subgraph(groups[key], key) # neighbors = graph.neighbors("103") # for n in neighbors: # print(n) #print graph.string() # print to screen graph.write(self.projname + ".dot") # write to simple.dot print "Wrote matrix.dot" graph.layout(prog='dot') graph.draw(self.projname + '.svg') # draw to png print "Wrote matrix.png"
def parse(self, path): fobj = open(path, "r") graph = HarrisGraph() graph.node_attr['shape'] = 'box' # Knoten hinzufuegen for line in fobj: line = line.strip() stratum = line.split(";") if stratum[1] == "context": graph.add_node(stratum[0], stratum[1], stratum[2], stratum[3], stratum[4]) # Kanten hinzufuegen fobj.close() fobj = open(path, "r") for line in fobj: line = line.strip() stratum = line.split(";") unitname = stratum[0] later = set(stratum[5].split(", ")) if stratum[1] == "context": for node in later: if node != "": graph.add_edge(unitname, node, "later") earlier = set(stratum[6].split(", ")) for node in earlier: if node != "": graph.add_edge(node, unitname, "earlier") equal = set(stratum[7].split(", ")) # for node in equal: # if node != "": # graph.add_edge(unitname, node, "concurrent") # partof = set(stratum[8].split(", ")) # for node in partof: # if node != "": # graph.add_edge(unitname, node, "concurrent") fobj.close() neighbors = graph.neighbors("103") for n in neighbors: print(n) print graph.string() # print to screen graph.write("matrix.dot") # write to simple.dot print "Wrote matrix.dot" graph.layout(prog='dot') graph.draw('matrix.svg') # draw to png print "Wrote matrix.png" self.draw("matrix.svg")