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.

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