capabilityMapComplexity.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { describe, expect, it } from "vitest";
  2. import { capabilityEdges } from "@/data/productCapabilityMap.js";
  3. import {
  4. getCapabilityGroupComplexity,
  5. groupComplexityById,
  6. nodeById,
  7. } from "@/capability-map/capabilityMapTypes.js";
  8. describe("能力群复杂度", () => {
  9. it("只把跨群有向边计入入度和出度", () => {
  10. const crossGroupEdgeCount = capabilityEdges.filter(
  11. (edge) =>
  12. nodeById.get(edge.source)?.groupId !==
  13. nodeById.get(edge.target)?.groupId,
  14. ).length;
  15. const totalInDegree = [...groupComplexityById.values()].reduce(
  16. (sum, complexity) => sum + complexity.inDegree,
  17. 0,
  18. );
  19. const totalOutDegree = [...groupComplexityById.values()].reduce(
  20. (sum, complexity) => sum + complexity.outDegree,
  21. 0,
  22. );
  23. expect(totalInDegree).toBe(crossGroupEdgeCount);
  24. expect(totalOutDegree).toBe(crossGroupEdgeCount);
  25. });
  26. it("智能体核心统计与当前权威关系图一致", () => {
  27. expect(getCapabilityGroupComplexity("agent-core")).toEqual({
  28. inDegree: 12,
  29. outDegree: 7,
  30. });
  31. });
  32. });