Created
August 11, 2011 22:14
-
-
Save aboSamoor/1140942 to your computer and use it in GitHub Desktop.
Pydot example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pydot | |
open('twopi2.gv.txt').read() | |
'digraph G {\n ranksep=3;\n ratio=auto;\n"1" [ label="01",shape="hexagon",style="filled",color="green" ];\n"2" [ label="02",shape="hexagon",style="filled",color="green" ];\n"3" [ label="02",shape="hexagon",style="filled",color="green" ];\n"1" -> "2" [ label=" ",color="blue",arrowhead="dot" ];\n"1" -> "3" [label="",color="blue",arrowhead=" | |
dot" ];\n}\n' | |
graph = pydot.graph_from_dot_data(open('twopi2.gv.txt').read()) | |
svg = graph.create_svg() | |
svg | |
# OUT: '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"\n "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [\n <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">\n]>\n<!-- Generated by Graphviz version 2.20.2 (Tue Mar  2 19:03:41 UTC 2010)\n For user: (rmyeid) Rami Al-rfou' -->\n<!-- Title: G Pages: 1 -->\n<svg width="134pt" height="314pt"\n viewBox="0.00 0.00 134.00 314.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 310)">\n<title>G</title>\n<polygon style="fill:white;stroke:white;" points="-4,4 -4,-310 130,-310 130,4 -4,4"/>\n<!-- 1 -->\n<g id="node1" class="node"><title>1</title>\n<polygon style="fill:green;stroke:green;" points="90,-288 76.5,-306 49.5,-306 36,-288 49.5,-270 76.5,-270 90,-288"/>\n<text text-anchor="middle" x="63" y="-283.9" style="font-family:Times New Roman;font-size:14.00;">01</text>\n</g>\n<!-- 2 -->\n<g id="node2" class="node"><title>2</title>\n<polygon style="fill:green;stroke:green;" points="54,-18 40.5,-36 13.5,-36 0,-18 13.5,-2.4869e-14 40.5,-0 54,-18"/>\n<text text-anchor="middle" x="27" y="-13.9" style="font-family:Times New Roman;font-size:14.00;">02</text>\n</g>\n<!-- 1->2 -->\n<g id="edge2" class="edge"><title>1->2</title>\n<path style="fill:none;stroke:blue;" d="M61,-270C54,-223 38,-98 30,-44"/>\n<ellipse style="fill:blue;stroke:blue;" cx="29.4962" cy="-39.9691" rx="4.00001" ry="4.00001"/>\n<text text-anchor="middle" x="50" y="-148.9" style="font-family:Times New Roman;font-size:14.00;"> </text>\n</g>\n<!-- 3 -->\n<g id="node3" class="node"><title>3</title>\n<polygon style="fill:green;stroke:green;" points="126,-18 112.5,-36 85.5,-36 72,-18 85.5,-2.4869e-14 112.5,-0 126,-18"/>\n<text text-anchor="middle" x="99" y="-13.9" style="font-family:Times New Roman;font-size:14.00;">02</text>\n</g>\n<!-- 1->3 -->\n<g id="edge4" class="edge"><title>1->3</title>\n<path style="fill:none;stroke:blue;" d="M65,-270C72,-223 88,-98 96,-44"/>\n<ellipse style="fill:blue;stroke:blue;" cx="96.5038" cy="-39.9691" rx="4.00001" ry="4.00001"/>\n<text text-anchor="middle" x="83" y="-148.9" style="font-family:Times New Roman;font-size:14.00;"> </text>\n</g>\n</g>\n</svg>\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment