Skip to content

Commit d18dace

Browse files
committed
refactor: use cytoscape-biological-flow npm package
Replaces the inline BiologicalFlowLayout engine with the standalone cytoscape-biological-flow npm package (v1.0.0), registered as a Cytoscape.js layout extension. - Adds cytoscape-biological-flow as a dependency - Registers the extension in CyjsLayout - Adds 'biological-flow' to CyjsAlgorithms - Removes the standalone BiologicalFlow engine implementation The layout algorithm is now maintained at: https://github.com/jmg421/cytoscape-biological-flow See: https://www.npmjs.com/package/cytoscape-biological-flow
1 parent f53431c commit d18dace

7 files changed

Lines changed: 44 additions & 224 deletions

File tree

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
"allotment": "1.18.1",
147147
"chroma-js": "^2.4.2",
148148
"cytoscape": "^3.34.0",
149+
"cytoscape-biological-flow": "^1.0.0",
149150
"cytoscape-canvas": "^3.0.1",
150151
"cytoscape-pdf-export": "^0.0.2",
151152
"cytoscape-svg": "^0.4.0",
@@ -190,4 +191,4 @@
190191
"zod": "^3.25.56",
191192
"zustand": "^4.4.7"
192193
}
193-
}
194+
}

src/models/LayoutModel/impl/BiologicalFlow/biologicalFlowLayout.test.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/models/LayoutModel/impl/BiologicalFlow/biologicalFlowLayout.ts

Lines changed: 0 additions & 153 deletions
This file was deleted.

src/models/LayoutModel/impl/Cyjs/Algorithms/biologicalFlow.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/**
2-
* Biological Flow Layout — contributed by Nodes Bio
2+
* Biological Flow Layout — powered by cytoscape-biological-flow
33
*
44
* A hierarchical layout optimized for biological pathway visualization:
5-
* - Topological sort assigns columns (left→right signal flow)
5+
* - Left-to-right signal flow direction
66
* - Barycenter heuristic minimizes edge crossings
77
* - Handles cycles via DFS back-edge removal
88
*
9-
* This is a client-side port of the LayoutOptimizer algorithm
10-
* originally developed for the MedMap pathway visualization tool.
9+
* Contributed by Nodes Bio (https://nodes.bio)
1110
*
12-
* @see https://github.com/cytoscape/cytoscape-web/issues/XXX
11+
* @see https://github.com/jmg421/cytoscape-biological-flow
1312
*/
1413
import { LayoutAlgorithm } from '../../..'
1514
import { LayoutAlgorithmType } from '../../../LayoutAlgorithm'
@@ -24,7 +23,7 @@ export const biologicalFlow: LayoutAlgorithm = {
2423
'Uses topological sort for layer assignment and barycenter heuristic ' +
2524
'for crossing minimization. Handles cycles gracefully.',
2625
parameters: {
27-
name: 'preset', // Uses preset because positions are pre-computed
26+
name: 'biological-flow',
2827
fit: true,
2928
padding: 80,
3029
animate: false,

src/models/LayoutModel/impl/Cyjs/Algorithms/cyjsAlgorithms.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { LayoutAlgorithm } from '../../../LayoutAlgorithm'
2+
import { biologicalFlow } from './biologicalFlow'
23
import { circle } from './circle'
34
import { concentric } from './concentric'
45
import { cose } from './cose'
56
import { grid } from './grid'
67

7-
const CyjsLayouts: LayoutAlgorithm[] = [grid, circle, cose, concentric]
8+
const CyjsLayouts: LayoutAlgorithm[] = [grid, circle, cose, concentric, biologicalFlow]
89

910
export const CyjsAlgorithms: Record<string, LayoutAlgorithm> =
1011
CyjsLayouts.reduce<Record<string, LayoutAlgorithm>>((acc, layout) => {

src/models/LayoutModel/impl/Cyjs/cyjsLayout.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import cytoscape, { EdgeDefinition, NodeDefinition } from 'cytoscape'
2+
import biologicalFlow from 'cytoscape-biological-flow'
23

34
import { IdType } from '../../../IdType'
45
import { Edge,Node } from '../../../NetworkModel'
56
import { LayoutAlgorithm } from '../../LayoutAlgorithm'
67
import { LayoutEngine } from '../../LayoutEngine'
78
import { CyjsAlgorithms } from './Algorithms/cyjsAlgorithms'
89

10+
// Register the biological-flow layout extension
11+
cytoscape.use(biologicalFlow)
12+
913
export const CyjsLayout: LayoutEngine = {
1014
// Cytoscape.js Layout
1115
name: 'Cytoscape.js',

0 commit comments

Comments
 (0)