cytoscape-fcose is a high-performance layout extension for Cytoscape.js, implementing the fCoSE (fast Compound Spring Embedder) algorithm. Developed by the i-Vis Lab at Bilkent University, it is significantly faster than its predecessor, CoSE, offering up to 2x speed improvement while maintaining similar aesthetic quality for graph visualizations. The current stable version is 2.2.0, with releases occurring a few times a year, indicating active maintenance. A key differentiator is its robust support for compound graphs and an extensive set of user-defined constraints including fixed node positions, alignment (vertical/horizontal), and relative placement, which can also be applied incrementally. It achieves this by combining spectral layout techniques with force-directed methods, making it suitable for complex network visualizations where both speed and structural clarity are paramount.
npm install cytoscape-fcoseVerified import paths — ran on the pinned version, not inferred.
This code initializes a Cytoscape.js instance, registers the `fcose` layout extension, defines a sample graph with compound nodes, and applies the fCoSE layout with animation and custom constraints for fixed node positions and alignment.
Review the fCoSE documentation for the new `fixedNodeConstraint`, `alignmentConstraint`, and `relativePlacementConstraint` options and update your layout configuration accordingly to leverage or properly handle these new features.
Consolidate your alignment constraint arrays to include all co-aligned nodes in a single sub-array, e.g., `vertical: [['node1', 'node2', 'node3']]`.
Ensure your project's installed `cytoscape` version is compatible with `^3.2.0` (e.g., `npm install cytoscape@^3.2.0`). Check your `package.json` and `npm list cytoscape`.
No direct action required for users; this was an internal dependency removal. Ensure you are on a recent version to benefit from performance improvements.
Ensure you call `cytoscape.use(fcose);` after importing the `cytoscape-fcose` module and before initializing any Cytoscape.js instances or calling `cy.layout({ name: 'fcose' })`.Verify that `import fcose from 'cytoscape-fcose';` and `cytoscape.use(fcose);` are executed at an appropriate place in your application setup, typically at the entry point or before any graph initialization.
Refactor your `alignmentConstraint` to group all nodes that should be aligned in a single direction (vertical or horizontal) into one sub-array. For example, change `vertical: [['n1', 'n2'], ['n1', 'n3']]` to `vertical: [['n1', 'n2', 'n3']]`.