example-complex.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import {DirectedGraphLayout} from "./graph/DirectedGraphLayout.js";
  2. import {SvgRenderer} from "./graph/SvgRenderer.js";
  3. let graph, svg,
  4. graphData = {
  5. numLayer: 10, maxPerLayer: 3, nodeList: [
  6. {label: 'Turdus', layer: 0},
  7. {label: 'Parus', layer: 0},
  8. {label: 'Falco', layer: 0},
  9. {label: 'Rubecula', layer: 0},
  10. {label: 'Corvus', layer: 0},
  11. {label: 'Sturnus', layer: 0},
  12. {label: 'Mycteria', layer: 0},
  13. {label: 'Ciconia', layer: 0},
  14. {label: 'Cygnus', layer: 0},
  15. {label: 'Cathartes', layer: 0},
  16. {label: 'Anas', layer: 0},
  17. {label: 'Atticora', layer: 0},
  18. {label: 'Hirundo', layer: 0},
  19. {label: 'Jabiru', layer: 0},
  20. {label: 'Ara', layer: 0},
  21. {label: 'Fringilla', layer: 0},
  22. {label: 'ZUGANG', layer: 0},
  23. {label: 'Tigrisoma', layer: 1},
  24. {label: 'UMFANG', layer: 1},
  25. {label: 'Harpia', layer: 9},
  26. {label: 'Rynchops', layer: 3},
  27. {label: 'Larus', layer: 4},
  28. {label: 'Troglodytes', layer: 1},
  29. {label: 'Anthracothorax', layer: 5},
  30. {label: 'Pandion', layer: 1},
  31. {label: 'Egretta', layer: 1},
  32. {label: 'Thryothorus', layer: 6},
  33. {label: 'Ciconia', layer: 1},
  34. {label: 'Athene', layer: 8},
  35. {label: 'Anhinga', layer: 7},
  36. {label: 'Philomachus', layer: 7},
  37. {label: 'Tetrao', layer: 1},
  38. {label: 'Podiceps', layer: 1},
  39. {label: 'Poecile', layer: 4},
  40. {label: 'Asio', layer: 1},
  41. {label: 'Strix', layer: 2},
  42. {label: 'Hippophae', layer: 1},
  43. {label: 'Silvia', layer: 2},
  44. {label: 'Columba', layer: 1},
  45. {label: 'Lanius', layer: 1},
  46. {label: 'Merganser', layer: 1},
  47. {label: 'Anser', layer: 1},
  48. {label: 'Eudocimus', layer: 1},
  49. {label: 'Catoptrophorus', layer: 1},
  50. {label: 'Pluvialis', layer: 1},
  51. {label: 'Aythya', layer: 1},
  52. {label: 'Cinclus', layer: 3}
  53. ], adjList: [
  54. [39],
  55. [41],
  56. [33, 45, 46],
  57. [36, 42],
  58. [36, 43],
  59. [36, 44],
  60. [38, 40],
  61. [38, 40],
  62. [17],
  63. [24],
  64. [34],
  65. [27],
  66. [25],
  67. [18],
  68. [22],
  69. [32],
  70. [31],
  71. [23],
  72. [35],
  73. [],
  74. [21, 28, 29],
  75. [28],
  76. [28],
  77. [26],
  78. [21, 29, 30],
  79. [28, 29, 30],
  80. [28, 29, 30],
  81. [20, 30],
  82. [19],
  83. [28],
  84. [28],
  85. [26],
  86. [23],
  87. [23],
  88. [35],
  89. [20],
  90. [37, 46],
  91. [46],
  92. [46],
  93. [46],
  94. [46],
  95. [46],
  96. [46],
  97. [46],
  98. [46],
  99. [46],
  100. [33]
  101. ]
  102. };
  103. graph = new DirectedGraphLayout({
  104. numLayer: graphData.numLayer
  105. });
  106. svg = new SvgRenderer({
  107. canvas: 'graphCanvas',
  108. gridSize: {
  109. meshWidth: 84,
  110. meshHeight: 66
  111. },
  112. // renderGrid: false
  113. });
  114. graph.render(graphData);
  115. svg.render(graph);