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.

123 lines
3.5 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. "6": {
  18. "id": "6",
  19. "attr": {
  20. "shape": "circle"
  21. }
  22. },
  23. "node1": {
  24. "id": "node1",
  25. "attr": {
  26. "shape": "doublecircle"
  27. }
  28. },
  29. "node2": {
  30. "id": "node2",
  31. "attr": {
  32. "shape": "doublecircle"
  33. }
  34. },
  35. "node3": {
  36. "id": "node3",
  37. "attr": {
  38. "shape": "doublecircle"
  39. }
  40. },
  41. "node4": {
  42. "id": "node4",
  43. "attr": {
  44. "shape": "diamond",
  45. "color": "red"
  46. }
  47. },
  48. "node5": {
  49. "id": "node5",
  50. "attr": {
  51. "shape": "square",
  52. "color": "blue",
  53. "width": 3
  54. }
  55. }
  56. },
  57. "edges": [
  58. {
  59. "from": "node1",
  60. "to": "node1",
  61. "type": "->",
  62. "attr": {
  63. "length": 170,
  64. "fontSize": 12,
  65. "label": "a"
  66. }
  67. },
  68. {
  69. "from": "node2",
  70. "to": "node3",
  71. "type": "->",
  72. "attr": {
  73. "length": 170,
  74. "fontSize": 12,
  75. "label": "b"
  76. }
  77. },
  78. {
  79. "from": "node1",
  80. "to": "node4",
  81. "type": "--",
  82. "attr": {
  83. "length": 170,
  84. "fontSize": 12,
  85. "label": "c"
  86. }
  87. },
  88. {
  89. "from": "node3",
  90. "to": "node4",
  91. "type": "->",
  92. "attr": {
  93. "length": 170,
  94. "fontSize": 12,
  95. "label": "d"
  96. }
  97. },
  98. {
  99. "from": "node4",
  100. "to": "node5",
  101. "type": "->",
  102. "attr": {
  103. "length": 170,
  104. "fontSize": 12
  105. }
  106. },
  107. {
  108. "from": "node5",
  109. "to": "6",
  110. "type": "->",
  111. "attr": {
  112. "length": 170,
  113. "fontSize": 12
  114. }
  115. }
  116. ]
  117. }
  118. );
  119. });