def createConfigurationGraph(modules, selectedmods, moddb, filename):
graph = pydot.Dot(graph_name="G", graph_type='digraph')
nodes = dict()
# add modules as nodes
for mod in modules:
tt = ", ".join(mod.provides) + " "
if mod.name in selectedmods:
fc = "#BEF781"
else:
fc = "white"
if moddb.getConflictingModules(mod):
nc = "#DF0101"
else:
nc = "black"
node = pydot.Node(mod.name, tooltip=tt,
style='filled', fillcolor=fc, color=nc, fontcolor=nc)
# node = pydot.Node(mod.name)
nodes[mod.name] = node
graph.add_node(node)
# add directed edges from modules to modules that satisfy at least one dependency
for src in modules:
dstmods = moddb.getSolutionCandidates(src)
#print(str(src) + ' --> ' + str(dstmods))
# don't show modules that are not in 'modules'
for dst in dstmods:
if dst not in modules: continue
tt = ", ".join(dstmods[dst]) + " "
edge = pydot.Edge(src.name, dst.name, tooltip=tt)
# edge = pydot.Edge(src.name, dst.name)
graph.add_edge(edge)
# add special directed edges for "modules" inclusion
for src in modules:
for dstname in src.modules:
dst = moddb[dstname]
edge = pydot.Edge(src.name, dst.name, color="green")
graph.add_edge(edge)
graph.write(filename)
评论列表
文章目录