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.

158 lines
3.8 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. "attr": {
  65. "shape": "circle"
  66. }
  67. },
  68. {
  69. "id": "C",
  70. "attr": {
  71. "shape": "circle"
  72. }
  73. }
  74. ],
  75. "edges": [
  76. {
  77. "from": "node1",
  78. "to": "node1",
  79. "type": "->",
  80. "attr": {
  81. "length": 170,
  82. "fontSize": 12,
  83. "label": "a"
  84. }
  85. },
  86. {
  87. "from": "node2",
  88. "to": "node3",
  89. "type": "->",
  90. "attr": {
  91. "length": 170,
  92. "fontSize": 12,
  93. "label": "b"
  94. }
  95. },
  96. {
  97. "from": "node1",
  98. "to": "node4",
  99. "type": "--",
  100. "attr": {
  101. "length": 170,
  102. "fontSize": 12,
  103. "label": "c"
  104. }
  105. },
  106. {
  107. "from": "node3",
  108. "to": "node4",
  109. "type": "->",
  110. "attr": {
  111. "length": 170,
  112. "fontSize": 12,
  113. "label": "d"
  114. }
  115. },
  116. {
  117. "from": "node4",
  118. "to": "node5",
  119. "type": "->",
  120. "attr": {
  121. "length": 170,
  122. "fontSize": 12
  123. }
  124. },
  125. {
  126. "from": "node5",
  127. "to": 6,
  128. "type": "->",
  129. "attr": {
  130. "length": 170,
  131. "fontSize": 12
  132. }
  133. },
  134. {
  135. "from": "A",
  136. "to": "B",
  137. "type": "->",
  138. "attr": {
  139. "length": 170,
  140. "fontSize": 12
  141. }
  142. },
  143. {
  144. "from": "A",
  145. "to": "C",
  146. "type": "->",
  147. "attr": {
  148. "length": 170,
  149. "fontSize": 12
  150. }
  151. }
  152. ]
  153. });
  154. });