Skip to content

Commit 3357eef

Browse files
committed
fix: resolve linter unused variable errors and improve generators
1 parent 53095ea commit 3357eef

File tree

2 files changed

+26
-39
lines changed

2 files changed

+26
-39
lines changed

src/generation/generators/perfect-variants.ts

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,38 +103,26 @@ export const generatePtolemaicEdges = (
103103
if (nodeCount === 0) return;
104104
if (nodeCount === 1) return;
105105

106-
// Partition nodes into 2-4 blocks (cliques)
107-
const numberBlocks = Math.min(nodeCount, rng.integer(2, 4));
108-
const blockSize = Math.floor(nodeCount / numberBlocks);
109-
const blocks: number[][] = [];
110-
111-
for (let index = 0; index < numberBlocks; index++) {
112-
const start = index * blockSize;
113-
const end = index === numberBlocks - 1 ? nodeCount : (index + 1) * blockSize;
114-
blocks.push(Array.from({ length: end - start }, (_, index) => start + index));
106+
// Simple approach: Create a path with some triangles
107+
// This is ptolemaic (chordal + distance-hereditary)
108+
// Build main path
109+
for (let index = 0; index < nodeCount - 1; index++) {
110+
edges.push({
111+
source: nodes[index].id,
112+
target: nodes[index + 1].id,
113+
});
115114
}
116115

117-
// Make each block a clique
118-
for (const block of blocks) {
119-
for (let index = 0; index < block.length; index++) {
120-
for (let index_ = index + 1; index_ < block.length; index_++) {
121-
edges.push({
122-
source: nodes[block[index]].id,
123-
target: nodes[block[index_]].id,
124-
});
125-
}
116+
// Add some chords to make small blocks (but keep it ptolemaic)
117+
// Every 3 nodes, close the triangle if we have enough nodes
118+
for (let index = 0; index < nodeCount - 2; index += 3) {
119+
if (index + 2 < nodeCount) {
120+
edges.push({
121+
source: nodes[index].id,
122+
target: nodes[index + 2].id,
123+
});
126124
}
127125
}
128-
129-
// Connect blocks in a tree structure (each block connects to next)
130-
for (let index = 0; index < blocks.length - 1; index++) {
131-
const u = blocks[index][rng.integer(0, blocks[index].length - 1)];
132-
const v = blocks[index + 1][rng.integer(0, blocks[index + 1].length - 1)];
133-
edges.push({
134-
source: nodes[u].id,
135-
target: nodes[v].id,
136-
});
137-
}
138126
};
139127

140128
/**
@@ -194,7 +182,6 @@ export const generateQuasiLineEdges = (
194182
} else {
195183
// Generate complete bipartite K_{m,n}
196184
const m = Math.floor(nodeCount / 2);
197-
const n = nodeCount - m;
198185

199186
// Partition nodes
200187
for (let index = 0; index < m; index++) {

src/utils/graph-adapters.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ export const toSpecifiedGraph = (core: CoreGraph, spec: GraphSpec): SpecifiedGra
191191
* @returns CoreGraph without spec
192192
*/
193193
export const fromSpecifiedGraph = (specified: SpecifiedGraph): CoreGraph => {
194-
195-
const { spec, ...core } = specified;
194+
195+
const { spec: _spec, ...core } = specified;
196196
return core;
197197
};
198198

@@ -217,8 +217,8 @@ export const toDocumentedGraph = (core: CoreGraph, meta: CoreGraphMeta): Documen
217217
* @returns CoreGraph without metadata
218218
*/
219219
export const fromDocumentedGraph = (document: DocumentedGraph): CoreGraph => {
220-
221-
const { meta, ...core } = document;
220+
221+
const { meta: _meta, ...core } = document;
222222
return core;
223223
};
224224

@@ -342,8 +342,8 @@ export const toCoreGraph = (graph:
342342
// Already CoreGraph
343343
if ("nodes" in graph && "edges" in graph && !("vertices" in graph)) {
344344
// Remove spec/meta if present
345-
346-
const { spec, meta, ...core } = graph as SpecifiedGraph &
345+
346+
const { spec: _spec, meta: _meta, ...core } = graph as SpecifiedGraph &
347347
DocumentedGraph &
348348
CoreGraph;
349349
return core;
@@ -377,7 +377,7 @@ export const toCoreGraph = (graph:
377377
* @param node
378378
*/
379379
const extractNodeAttributes = (node: CoreGraphNode): Record<string, unknown> | undefined => {
380-
const { id, label, type, partition, ...rest } = node;
380+
const { id: _id, label: _label, type: _type, partition: _partition, ...rest } = node;
381381
return Object.keys(rest).length > 0 ? rest : undefined;
382382
};
383383

@@ -386,7 +386,7 @@ const extractNodeAttributes = (node: CoreGraphNode): Record<string, unknown> | u
386386
* @param edge
387387
*/
388388
const extractEdgeAttributes = (edge: CoreGraphEdge): Record<string, unknown> | undefined => {
389-
const { source, target, weight, directed, type, ...rest } = edge;
389+
const { source: _source, target: _target, weight: _weight, directed: _directed, type: _type, ...rest } = edge;
390390
return Object.keys(rest).length > 0 ? rest : undefined;
391391
};
392392

@@ -395,7 +395,7 @@ const extractEdgeAttributes = (edge: CoreGraphEdge): Record<string, unknown> | u
395395
* @param node
396396
*/
397397
const extractGmlNodeAttributes = (node: GmlGraphNode): Record<string, unknown> | undefined => {
398-
const { id, label, ...rest } = node;
398+
const { id: _id, label: _label, ...rest } = node;
399399
return Object.keys(rest).length > 0 ? rest : undefined;
400400
};
401401

@@ -404,6 +404,6 @@ const extractGmlNodeAttributes = (node: GmlGraphNode): Record<string, unknown> |
404404
* @param edge
405405
*/
406406
const extractGmlEdgeAttributes = (edge: GmlGraphEdge): Record<string, unknown> | undefined => {
407-
const { source, target, weight, directed, ...rest } = edge;
407+
const { source: _source, target: _target, weight: _weight, directed: _directed, ...rest } = edge;
408408
return Object.keys(rest).length > 0 ? rest : undefined;
409409
};

0 commit comments

Comments
 (0)