example-simple.js 705 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {DirectedGraphLayout} from "./graph/DirectedGraphLayout.js";
  2. import {SvgRenderer} from "./graph/SvgRenderer.js";
  3. let graph, svg,
  4. graphData = {
  5. numLayer: 4,
  6. maxPerLayer: 2,
  7. nodeList: [
  8. {label: 'Rubecula', layer: 0},
  9. {label: 'Turdus', layer: 3},
  10. {label: 'Corvus', layer: 1},
  11. {label: 'Falco', layer: 1},
  12. {label: 'Cathartes', layer: 2},
  13. {label: 'Parus', layer: 0}
  14. ],
  15. adjList: [
  16. [2, 3, 4],
  17. [],
  18. [1],
  19. [],
  20. [],
  21. [2]
  22. ]
  23. };
  24. graph = new DirectedGraphLayout({
  25. numLayer: graphData.numLayer,
  26. compacted: false
  27. });
  28. svg = new SvgRenderer({
  29. canvas: 'graphCanvas',
  30. gridSize: {
  31. meshWidth: 100,
  32. meshHeight: 100
  33. }
  34. });
  35. graph.render(graphData);
  36. svg.render(graph);