CodeSampleX

샘플

cytoscape 3.34.3: cytoscape

검증된 샘플 — npm cytoscape 3.34.3: cytoscape. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: initializes headless Cytoscape core instance with nodes…

sha256:77c6abdfe8710877354ebe72d2c9cff092a9448d42baaa590a13d253bd86319e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-13

케이스

HOW
목표
verify pkg:npm/cytoscape@3.34.3
패키지
심벌
  • cytoscape
생성일
2026-09-13T13:45:39Z

컨트랙트

  1. initializes headless Cytoscape core instance with nodes and edges and reports correct element counts
  2. queries graph elements by id and reads node data attributes
  3. traverses graph neighborhoods using connected edges and outgoers
  4. adds elements dynamically to an existing graph instance
  5. calculates shortest paths and distances between nodes using Dijkstra algorithm

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/cytoscape@3.34.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/cytoscape@3.34.3

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:985f2dd81575e1c330b156e0dcb2b246a426552d2bf3f8bab5132868e663a3b5","contract":["initializes headless Cytoscape core instance with nodes and edges and reports correct element counts","queries graph elements by id and reads node data attributes","traverses graph neighborhoods using connected edges and outgoers","adds elements dynamically to an existing graph instance","calculates shortest paths and distances between nodes using Dijkstra algorithm"],"goal":"verify pkg:npm/cytoscape@3.34.3","kind":"HOW","packages":["pkg:npm/cytoscape@3.34.3"],"schemaVersion":1,"symbols":["cytoscape"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/cytoscape@3.34.3"],"schemaVersion":1,"subject":"pkg:npm/cytoscape@3.34.3","symbols":["cytoscape"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-cytoscape",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-cytoscape",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "cytoscape": "3.34.3"
      }
    },
    "node_modules/cytoscape": {
      "version": "3.34.3",
      "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.34.3.tgz",
      "integrity": "sha512-yfYGhRcGAntq6YBD583j4n0Eg3jIxvWmZtz/5uz9UYkeIStSlMxuUja+ec5j3iBD8nv1rwaOAYMW09tBdkSeaQ==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10"
      }
    }
  }
}
package.json
{
  "name": "sample-cytoscape",
  "version": "1.0.0",
  "description": "Clean-room verification sample for pkg:npm/cytoscape@3.34.3",
  "type": "module",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "cytoscape": "3.34.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/cytoscape@3.34.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/cytoscape@3.34.3"
  ],
  "symbols": [
    "cytoscape"
  ]
}
src/index.js
import cytoscape from 'cytoscape';

/**
 * Creates a headless Cytoscape instance with given elements and options.
 * @param {Array<object>} elements - Initial graph elements (nodes and edges).
 * @param {object} [options={}] - Additional Cytoscape configuration options.
 * @returns {object} Cytoscape core instance.
 */
export function createGraph(elements = [], options = {}) {
  return cytoscape({
    headless: true,
    elements,
    ...options
  });
}

/**
 * Adds nodes and edges to an existing Cytoscape instance.
 * @param {object} cy - Cytoscape instance.
 * @param {Array<object>} elements - Elements to add.
 * @returns {object} Added elements collection.
 */
export function addElements(cy, elements) {
  return cy.add(elements);
}

/**
 * Computes the shortest path from a source selector to a target selector using Dijkstra.
 * @param {object} cy - Cytoscape instance.
 * @param {string} rootSelector - Selector for root node.
 * @param {string} targetSelector - Selector for target node.
 * @returns {{ path: object, distance: number }} Shortest path collection and distance.
 */
export function findShortestPath(cy, rootSelector, targetSelector) {
  const dijkstra = cy.elements().dijkstra(rootSelector);
  const targetNode = cy.$(targetSelector);
  return {
    path: dijkstra.pathTo(targetNode),
    distance: dijkstra.distanceTo(targetNode)
  };
}

export { cytoscape };
test/contract.mjs
import assert from 'node:assert';
import cytoscape from 'cytoscape';
import { createGraph, addElements, findShortestPath } from '../src/index.js';

// 1. initializes headless Cytoscape core instance with nodes and edges and reports correct element counts
const cy = createGraph([
  { data: { id: 'a', label: 'Node A' } },
  { data: { id: 'b', label: 'Node B' } },
  { data: { id: 'ab', source: 'a', target: 'b' } }
]);
assert.strictEqual(typeof cytoscape, 'function', 'cytoscape export must be a factory function');
assert.strictEqual(typeof cytoscape.version, 'string', 'cytoscape must expose version string');
assert.strictEqual(cy.nodes().length, 2, 'cy.nodes().length must equal 2');
assert.strictEqual(cy.edges().length, 1, 'cy.edges().length must equal 1');

// 2. queries graph elements by id and reads node data attributes
const nodeA = cy.getElementById('a');
assert.strictEqual(nodeA.id(), 'a', 'nodeA id must be "a"');
assert.strictEqual(nodeA.data('label'), 'Node A', 'nodeA data label must be "Node A"');

// 3. traverses graph neighborhoods using connected edges and outgoers
const outgoers = nodeA.outgoers();
assert.strictEqual(outgoers.has(cy.getElementById('ab')), true, 'outgoers must include edge ab');
assert.strictEqual(outgoers.has(cy.getElementById('b')), true, 'outgoers must include target node b');

// 4. adds elements dynamically to an existing graph instance
addElements(cy, [
  { group: 'nodes', data: { id: 'c', label: 'Node C' } },
  { group: 'edges', data: { id: 'bc', source: 'b', target: 'c' } }
]);
assert.strictEqual(cy.nodes().length, 3, 'cy.nodes().length must equal 3 after add');
assert.strictEqual(cy.edges().length, 2, 'cy.edges().length must equal 2 after add');

// 5. calculates shortest paths and distances between nodes using Dijkstra algorithm
const { path: pathToC, distance } = findShortestPath(cy, '#a', '#c');
assert.strictEqual(pathToC.length, 5, 'path length from a to c must be 5 elements');
assert.strictEqual(distance, 2, 'distance from a to c must be 2');

console.log('Contract assertions passed.');

오리진 시더

익명