Drawing Multigraphs

geremy condra debatem1 at gmail.com
Tue Jun 1 14:56:02 EDT 2010


On Tue, Jun 1, 2010 at 11:24 AM, Nima <nima.irt at gmail.com> wrote:
> 2010/6/1 geremy condra <debatem1 at gmail.com>
>>
>> We use Dot in Graphine, and it works well. It's also very easy to
>> output to.
>
>
>> Graphine is a flexible, easy-to-use graph library for Python 3.
>
> I always knew a day would come when I'd need to use Python 3. And I've
> been so stupid thinking I could run away from this everlasting misery!
> Can you give me an example of drawing a simple graph by Graphine?

from graph.base import Graph
from graph.extras import dot
from subprocess import getstatusoutput

# build a circular graph
g = Graph(edges=['ab', 'bc', 'cd', 'da'])

# build the drawing tool
drawer = dot.DotGenerator()

# populate the output file
with open('graph.dot', 'w') as f:
    output = drawer.draw(g, "my_graph")
    f.write(output)

# call circo, which will produce the best results here
status, output = getstatusoutput("circo -Tgif -o graph.gif -v graph.dot")


Geremy Condra



More information about the Python-list mailing list