@tscircuit/hypergraph 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -63,13 +63,16 @@ type HyperGraph = {
63
63
  ports: RegionPort[];
64
64
  regions: Region[];
65
65
  };
66
- type SerializedGraphPort = Omit<RegionPort, "edges"> & {
66
+ type SerializedGraphPort = {
67
67
  portId: PortId;
68
68
  region1Id: RegionId;
69
69
  region2Id: RegionId;
70
+ d: any;
70
71
  };
71
- type SerializedGraphRegion = Omit<Region, "points" | "assignments"> & {
72
+ type SerializedGraphRegion = {
73
+ regionId: RegionId;
72
74
  pointIds: PortId[];
75
+ d: any;
73
76
  assignments?: SerializedRegionPortAssignment[];
74
77
  };
75
78
  type SerializedRegionPortAssignment = {
@@ -294,6 +297,13 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
294
297
  rippingEnabled?: boolean;
295
298
  ripCost?: number;
296
299
  });
300
+ getConstructorParams(): {
301
+ inputGraph: SerializedHyperGraph;
302
+ inputConnections: SerializedConnection[];
303
+ greedyMultiplier: number;
304
+ rippingEnabled: boolean;
305
+ ripCost: number;
306
+ };
297
307
  computeH(candidate: CandidateType): number;
298
308
  /**
299
309
  * OVERRIDE THIS
@@ -398,6 +408,10 @@ declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
398
408
  visualize(): GraphicsObject;
399
409
  }
400
410
 
411
+ declare const convertHyperGraphToSerializedHyperGraph: (graph: HyperGraph) => SerializedHyperGraph;
412
+
413
+ declare const convertConnectionsToSerializedConnections: (connections: Connection[]) => SerializedConnection[];
414
+
401
415
  /**
402
416
  * Applies a transformation matrix to all points in a graph.
403
417
  * Transforms region bounds, region centers, and port positions.
@@ -410,4 +424,4 @@ declare const rotateGraph90Degrees: (graph: JumperGraph) => JumperGraph;
410
424
 
411
425
  declare const calculateGraphBounds: (regions: JRegion[]) => Bounds;
412
426
 
413
- export { type Candidate, type Connection, type ConnectionId, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, type PortId, type Region, type RegionId, type RegionPort, type RegionPortAssignment, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SolvedRoute, type XYConnection, applyTransformToGraph, calculateGraphBounds, createGraphWithConnectionsFromBaseGraph, generateJumperGrid, generateJumperX4Grid, rotateGraph90Degrees };
427
+ export { type Candidate, type Connection, type ConnectionId, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, type PortId, type Region, type RegionId, type RegionPort, type RegionPortAssignment, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SolvedRoute, type XYConnection, applyTransformToGraph, calculateGraphBounds, convertConnectionsToSerializedConnections, convertHyperGraphToSerializedHyperGraph, createGraphWithConnectionsFromBaseGraph, generateJumperGrid, generateJumperX4Grid, rotateGraph90Degrees };
package/dist/index.js CHANGED
@@ -1562,6 +1562,36 @@ var convertSerializedHyperGraphToHyperGraph = (inputGraph) => {
1562
1562
  };
1563
1563
  };
1564
1564
 
1565
+ // lib/convertHyperGraphToSerializedHyperGraph.ts
1566
+ var convertHyperGraphToSerializedHyperGraph = (graph) => {
1567
+ const serializedPorts = graph.ports.map((port) => ({
1568
+ portId: port.portId,
1569
+ region1Id: port.region1.regionId,
1570
+ region2Id: port.region2.regionId,
1571
+ d: port.d
1572
+ }));
1573
+ const serializedRegions = graph.regions.map(
1574
+ (region) => ({
1575
+ regionId: region.regionId,
1576
+ pointIds: region.ports.map((port) => port.portId),
1577
+ d: region.d
1578
+ })
1579
+ );
1580
+ return {
1581
+ ports: serializedPorts,
1582
+ regions: serializedRegions
1583
+ };
1584
+ };
1585
+
1586
+ // lib/convertConnectionsToSerializedConnections.ts
1587
+ var convertConnectionsToSerializedConnections = (connections) => {
1588
+ return connections.map((conn) => ({
1589
+ connectionId: conn.connectionId,
1590
+ startRegionId: conn.startRegion.regionId,
1591
+ endRegionId: conn.endRegion.regionId
1592
+ }));
1593
+ };
1594
+
1565
1595
  // lib/convertSerializedConnectionsToConnections.ts
1566
1596
  var convertSerializedConnectionsToConnections = (inputConnections, graph) => {
1567
1597
  const connections = [];
@@ -1767,6 +1797,17 @@ var HyperGraphSolver = class extends BaseSolver {
1767
1797
  ripCost = 0;
1768
1798
  lastCandidate = null;
1769
1799
  visitedPointsForCurrentConnection = /* @__PURE__ */ new Map();
1800
+ getConstructorParams() {
1801
+ return {
1802
+ inputGraph: convertHyperGraphToSerializedHyperGraph(this.graph),
1803
+ inputConnections: convertConnectionsToSerializedConnections(
1804
+ this.connections
1805
+ ),
1806
+ greedyMultiplier: this.greedyMultiplier,
1807
+ rippingEnabled: this.rippingEnabled,
1808
+ ripCost: this.ripCost
1809
+ };
1810
+ }
1770
1811
  computeH(candidate) {
1771
1812
  return this.estimateCostToEnd(candidate.port);
1772
1813
  }
@@ -2420,6 +2461,8 @@ export {
2420
2461
  JumperGraphSolver,
2421
2462
  applyTransformToGraph,
2422
2463
  calculateGraphBounds,
2464
+ convertConnectionsToSerializedConnections,
2465
+ convertHyperGraphToSerializedHyperGraph,
2423
2466
  createGraphWithConnectionsFromBaseGraph,
2424
2467
  generateJumperGrid,
2425
2468
  generateJumperX4Grid,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/hypergraph",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",