def graphname(name): names = [name] data = [pair for pair in get_tuples()] # make some passes through the data to accumulate connected vertices. for i in range(1): ids = [pair[0] for pair in data if pair[1] in names] names = [pair[1] for pair in data if pair[0] in ids] graph = ConcurrencyGraph() graph.add_dataset(data=[pair for pair in data if pair[0] in ids], min_occurences=0) nodejs = '\n'.join(["g.addNode('%s');" % node for node in graph.gr.nodes()]) edgejs = '\n'.join(["g.addEdge('%s', '%s');" % edge for edge in graph.gr.edges()]) return render_template('webgraph.html', name=name, graphdatajs=Markup(nodejs+edgejs))
import os import sys from concurrency_graph import ConcurrencyGraph from nytimes import get_tuples if __name__ == "__main__": graph = ConcurrencyGraph(graph_attrs=[("sep", '"+1"'), ("outputorder", "edgesfirst"), ("overlap", "scalexy")]) graph.add_dataset( data=get_tuples(), min_occurences=8, min_fontsize=4, max_fontsize=28, node_attrs=[("shape", "oval"), ("style", "filled")], ) with open("graph.dot", "w") as f: f.write(graph.write()) if "--draw" in sys.argv: print "Drawing graph with neato.." os.system("neato -Tgif -ograph.gif graph.dot")