Advertisement
Guest User

Untitled

a guest
Feb 24th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. #include <gvc.h>
  2. #include <stdio.h>
  3.  
  4. char* toDot(char* ing, int* size)
  5. {
  6. char* serializedData;
  7. GVC_t* gvc = gvContext();
  8. Agraph_t* G = agmemread(ing);
  9.  
  10. agset(G, (char*) "label", (char*)"");
  11. gvLayout (gvc, G, "dot");
  12.  
  13. gvRenderData(gvc, G, "svg", &serializedData, size);
  14. gvFreeLayout(gvc, G);
  15.  
  16. agclose (G);
  17.  
  18. gvFreeContext(gvc);
  19. return serializedData;
  20. }
  21.  
  22. static char* data =
  23. "digraph N {\n\
  24. graph [fontname=Helvetica nodesep=0.25 ranksep=0.25 remincross=true label=\"Petri net\\n&Omega;=((p4=0) &and; (init=0) &and; (p3=0) &and; (p9=0) &and; (p2=0) &and; (final=0) &and; (p5=0) &and; (p7=0) &and; (p1=0) &and; (p8=0) &and; (p6=0))\"]\n\
  25. node [fontname=Helvetica fixedsize=true width=.3 height=.3 label=\"\" style=filled]\n\
  26. edge [fontname=Helvetica color=white arrowhead=none weight=20.0]\n\
  27. \n\
  28. // interface\n\
  29. \n\
  30. // places\n\
  31. node [shape=circle fillcolor=white]\n\
  32. p10 []\n\
  33. p10_l [style=invis]\n\
  34. p10_l -> p10 [headlabel=final]\n\
  35. p11 [fillcolor=black peripheries=2 height=.2 width=.2 ]\n\
  36. p11_l [style=invis]\n\
  37. p11_l -> p11 [headlabel=init]\n\
  38. p1 []\n\
  39. p1_l [style=invis]\n\
  40. p1_l -> p1 [headlabel=p1]\n\
  41. p6 []\n\
  42. p6_l [style=invis]\n\
  43. p6_l -> p6 [headlabel=p2]\n\
  44. p4 []\n\
  45. p4_l [style=invis]\n\
  46. p4_l -> p4 [headlabel=p3]\n\
  47. p7 []\n\
  48. p7_l [style=invis]\n\
  49. p7_l -> p7 [headlabel=p4]\n\
  50. p2 []\n\
  51. p2_l [style=invis]\n\
  52. p2_l -> p2 [headlabel=p5]\n\
  53. p3 []\n\
  54. p3_l [style=invis]\n\
  55. p3_l -> p3 [headlabel=p6]\n\
  56. p5 []\n\
  57. p5_l [style=invis]\n\
  58. p5_l -> p5 [headlabel=p7]\n\
  59. p9 []\n\
  60. p9_l [style=invis]\n\
  61. p9_l -> p9 [headlabel=p8]\n\
  62. p8 []\n\
  63. p8_l [style=invis]\n\
  64. p8_l -> p8 [headlabel=p9]\n\
  65. // transitions\n\
  66. node [shape=box]\n\
  67. t7 []\n\
  68. t7_l [style=invis]\n\
  69. t7_l -> t7 [headlabel=t1]\n\
  70. t1 []\n\
  71. t1_l [style=invis]\n\
  72. t1_l -> t1 [headlabel=t2]\n\
  73. t6 []\n\
  74. t6_l [style=invis]\n\
  75. t6_l -> t6 [headlabel=t3]\n\
  76. t8 []\n\
  77. t8_l [style=invis]\n\
  78. t8_l -> t8 [headlabel=t4]\n\
  79. t4 []\n\
  80. t4_l [style=invis]\n\
  81. t4_l -> t4 [headlabel=t5]\n\
  82. t5 []\n\
  83. t5_l [style=invis]\n\
  84. t5_l -> t5 [headlabel=t6]\n\
  85. t2 []\n\
  86. t2_l [style=invis]\n\
  87. t2_l -> t2 [headlabel=t7]\n\
  88. t3 []\n\
  89. t3_l [style=invis]\n\
  90. t3_l -> t3 [headlabel=t8]\n\
  91. \n\
  92. // inner cluster\n\
  93. subgraph cluster1\n\
  94. {\n\
  95. t7 t7_l t1 t1_l t6 t6_l t8 t8_l t4 t4_l t5 t5_l t2 t2_l t3 t3_l\n\
  96. p10 p10_l p11 p11_l p1 p1_l p6 p6_l p4 p4_l p7 p7_l p2 p2_l p3 p3_l p5 p5_l p9 p9_l p8 p8_l\n\
  97. label=\"\" style=invis\n\
  98. }\n\
  99. \n\
  100. // arcs\n\
  101. edge [fontname=Helvetica arrowhead=normal color=black]\n\
  102. t3 -> p10 []\n\
  103. p11 -> t7 []\n\
  104. t7 -> p1 []\n\
  105. p1 -> t1 []\n\
  106. t7 -> p6 []\n\
  107. p6 -> t6 []\n\
  108. t1 -> p4 []\n\
  109. p4 -> t8 []\n\
  110. t6 -> p7 []\n\
  111. p7 -> t4 []\n\
  112. t6 -> p2 []\n\
  113. p2 -> t5 []\n\
  114. t4 -> p3 []\n\
  115. t8 -> p3 []\n\
  116. p3 -> t2 []\n\
  117. p5 -> t2 []\n\
  118. t5 -> p5 []\n\
  119. p9 -> t3 []\n\
  120. t2 -> p9 []\n\
  121. t2 -> p8 []\n\
  122. p8 -> t3 []\n\
  123. \n\
  124. \n\
  125. \n\
  126. \n\
  127. \n\
  128. \n\
  129. \n\
  130. \n\
  131. }\n";
  132.  
  133. main()
  134. {
  135. int sz;
  136. /* fputs(data, stdout); */
  137.  
  138. char* out = toDot (data, &sz);
  139.  
  140. fwrite(out, sizeof(char), sz, stdout);
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement