예제 #1
0
def getGraphvizDotFormat(graph):
    nodes, edges = graph

    #digraph { a -> b; b -> c; c -> d; d -> a; }
    content = "digraph {\n"
    for u in nodes:
        if u in edges:
            for v in edges[u]:
                content += "\"%s\" -> \"%s\";\n" % (u.replace(
                    '-', '_'), v.replace('-', '_'))

    # add nodes with no outcoming edge
    leaves = getLeafPackages(graph)
    for leaf in leaves:
        content += "\"%s\" [style=filled, fillcolor=orange]" % leaf.replace(
            '-', '_')

    # add nodes with no incomming edge
    roots = getRootPackages(graph)
    for root in roots:
        content += "\"%s\" [style=filled, fillcolor=red3]" % root.replace(
            '-', '_')

    # add cyclic deps
    scc = getSCC(graph)

    colors = ['purple', 'salmon', 'forestgreen', 'dodgerblue', 'yellow']
    col_len = len(colors)

    counter = 0
    for comp in scc:
        if len(comp) > 1:
            for elem in comp:
                content += "\"%s\" [style=filled, fillcolor=%s]" % (
                    elem.replace('-', '_'), colors[counter])
            counter = (counter + 1) % col_len

    content += "}\n"
    return content
예제 #2
0
def getGraphvizDotFormat(graph):
	nodes, edges = graph

	#digraph { a -> b; b -> c; c -> d; d -> a; }
	content = "digraph {\n"
	for u in nodes:
		if u in edges:
			for v in edges[u]:
				content += "%s -> %s;\n" % (u.replace('-', '_'), v.replace('-', '_'))

	# add nodes with no outcoming edge
	leaves = getLeafPackages(graph)
	for leaf in leaves:
		content += "%s [style=filled, fillcolor=orange]" % leaf.replace('-', '_')

	# add nodes with no incomming edge
	roots = getRootPackages(graph)
	for root in roots:
		content += "%s [style=filled, fillcolor=red3]" % root.replace('-', '_')

	# add cyclic deps
	scc = getSCC(graph)

	colors = ['purple', 'salmon', 'forestgreen', 'dodgerblue', 'yellow']
	col_len = len(colors)

	counter = 0
	for comp in scc:
		if len(comp) > 1:
			for elem in comp:
				content += "%s [style=filled, fillcolor=%s]" % (elem.replace('-', '_'), colors[counter])
			counter = (counter + 1) % col_len


	content += "}\n"
	return content
예제 #3
0
				print "No graph generated, package probably does not exist"
				exit(0)

			nodes, _ = graph
			subgraph_cnt = len(nodes)
			
		scan_time_end = time()
		print strftime("Completed in %Hh %Mm %Ss", gmtime(scan_time_end - scan_time_start))
		if pkg_name != "":
			print "%s nodes of %s" % (graph_cnt, subgraph_cnt)
		else:
			print "%s nodes in total" % (graph_cnt)


		if options.cyclic:
			scc = getSCC(graph)

			for comp in scc:
				if len(comp) > 1:
					printSCC(comp)

		elif options.leaves:
			leaves = getLeafPackages(graph)
			for leaf in leaves:
				print leaf

		elif options.roots:
			roots = getRootPackages(graph)
			for root in roots:
				print root
예제 #4
0
                print "No graph generated, package probably does not exist"
                exit(0)

            nodes, _ = graph
            subgraph_cnt = len(nodes)

        scan_time_end = time()
        print strftime("Completed in %Hh %Mm %Ss",
                       gmtime(scan_time_end - scan_time_start))
        if pkg_name != "":
            print "%s nodes of %s" % (subgraph_cnt, graph_cnt)
        else:
            print "%s nodes in total" % (graph_cnt)

        if options.cyclic:
            scc = getSCC(graph)

            for comp in scc:
                if len(comp) > 1:
                    printSCC(comp)

        elif options.leaves:
            leaves = getLeafPackages(graph)
            for leaf in leaves:
                print leaf

        elif options.roots:
            roots = getRootPackages(graph)
            for root in roots:
                print root