vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
3.1 KiB

  1. var assert = require('assert'),
  2. fs = require('fs'),
  3. dot = require('../src/graph/dotparser.js');
  4. fs.readFile('test/dot.txt', function (err, data) {
  5. data = String(data);
  6. var graph = dot.parseDOT(data);
  7. assert.deepEqual(graph, {
  8. "type": "digraph",
  9. "id": "test_graph",
  10. "rankdir": "LR",
  11. "size": "8,5",
  12. "font": "arial",
  13. "nodes": [
  14. {
  15. "id": "node1",
  16. "attr": {
  17. "shape": "doublecircle"
  18. }
  19. },
  20. {
  21. "id": "node2",
  22. "attr": {
  23. "shape": "doublecircle"
  24. }
  25. },
  26. {
  27. "id": "node3",
  28. "attr": {
  29. "shape": "doublecircle"
  30. }
  31. },
  32. {
  33. "id": "node4",
  34. "attr": {
  35. "shape": "diamond",
  36. "color": "red"
  37. }
  38. },
  39. {
  40. "id": "node5",
  41. "attr": {
  42. "shape": "square",
  43. "color": "blue",
  44. "width": 3
  45. }
  46. },
  47. {
  48. "id": 6,
  49. "attr": {
  50. "shape": "circle"
  51. }
  52. },
  53. {
  54. "id": "A",
  55. "attr": {
  56. "shape": "circle"
  57. }
  58. },
  59. {
  60. "id": "B",
  61. "attr": {
  62. "shape": "circle"
  63. }
  64. },
  65. {
  66. "id": "C",
  67. "attr": {
  68. "shape": "circle"
  69. }
  70. }
  71. ],
  72. "edges": [
  73. {
  74. "from": "node1",
  75. "to": "node1",
  76. "type": "->",
  77. "attr": {
  78. "length": 170,
  79. "fontSize": 12,
  80. "label": "a"
  81. }
  82. },
  83. {
  84. "from": "node2",
  85. "to": "node3",
  86. "type": "->",
  87. "attr": {
  88. "length": 170,
  89. "fontSize": 12,
  90. "label": "b"
  91. }
  92. },
  93. {
  94. "from": "node1",
  95. "to": "node4",
  96. "type": "--",
  97. "attr": {
  98. "length": 170,
  99. "fontSize": 12,
  100. "label": "c"
  101. }
  102. },
  103. {
  104. "from": "node3",
  105. "to": "node4",
  106. "type": "->",
  107. "attr": {
  108. "length": 170,
  109. "fontSize": 12,
  110. "label": "d"
  111. }
  112. },
  113. {
  114. "from": "node4",
  115. "to": "node5",
  116. "type": "->",
  117. "attr": {
  118. "length": 170,
  119. "fontSize": 12
  120. }
  121. },
  122. {
  123. "from": "node5",
  124. "to": 6,
  125. "type": "->",
  126. "attr": {
  127. "length": 170,
  128. "fontSize": 12
  129. }
  130. },
  131. {
  132. "from": "A",
  133. "to": {
  134. "nodes": [
  135. {
  136. "id": "B",
  137. "attr": {
  138. "shape": "circle"
  139. }
  140. },
  141. {
  142. "id": "C",
  143. "attr": {
  144. "shape": "circle"
  145. }
  146. }
  147. ]
  148. },
  149. "type": "->",
  150. "attr": {
  151. "length": 170,
  152. "fontSize": 12
  153. }
  154. }
  155. ],
  156. "subgraphs": [
  157. {
  158. "nodes": [
  159. {
  160. "id": "B",
  161. "attr": {
  162. "shape": "circle"
  163. }
  164. },
  165. {
  166. "id": "C",
  167. "attr": {
  168. "shape": "circle"
  169. }
  170. }
  171. ]
  172. }
  173. ]
  174. });
  175. });