Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cosmograph/cosmos

Package Overview
Dependencies
Maintainers
0
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmograph/cosmos

GPU-based force graph layout and rendering

  • 2.0.0-beta.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
932
increased by76.18%
Maintainers
0
Weekly downloads
 
Created
Source

🌌 Cosmos

GPU-accelerated Force Graph

Cosmos is a WebGL Force Graph layout algorithm and rendering engine. All the computations and drawing are happening on the GPU in fragment and vertex shaders, avoiding expensive memory operations.

It enables real-time simulation of network graphs consisting of hundreds of thousands of points and links on modern hardware.

📺 Comparison with other libraries

🎮 Try Cosmos on StackBlitz


Quick Start

Install the package:

npm install @cosmograph/cosmos

Configure the graph, set data, and run the simulation:

import { Graph } from '@cosmograph/cosmos';
import { pointPositions, links } from './data';

const div = document.querySelector('div');
const config = {
  simulationRepulsion: 0.5,
  renderLinks: true,
  onClick: (pointIndex) => {
    console.log('Clicked point index: ', pointIndex);
  },
};

const graph = new Graph(div, config);

graph.setPointPositions(pointPositions);
graph.setLinks(links);
graph.render();
  • pointPositions: A Float32Array of [x1, y1, x2, y2, ..., xN, yN].
  • links: A Float32Array of [sourceIndex1, targetIndex1, ..., sourceIndexN, targetIndexN].

What's New in v2.0?

Cosmos v2.0 introduces significant improvements in performance and data handling:

  • Enhanced data structures with WebGL-compatible formats.
  • Methods like setPointPositions and setLinks replace setData for improved efficiency.
  • Direct control over point and link attributes via Float32Array (e.g., colors, sizes, widths).
  • Updated event handling based on indices instead of objects.
  • New Clustering Feature (setPointClusters, setClusterPositions and setPointClusterStrength).
  • Ability to drag points.

Check the Migration Guide for details.


Examples


Showcase (via cosmograph.app)


Known Issues

  • Starting from version 15.4, iOS has stopped supporting the key WebGL extension powering our Many-Body force implementation (EXT_float_blend). We're investigating this issue and exploring solutions.

Documentation


License

CC-BY-NC-4.0

Cosmos is free for non-commercial usage. If you're a scientist, artist, educator, journalist, or student, we'd love to hear how you're using Cosmos! For commercial projects, please reach out.


Contact

📩 hi@cosmograph.app

Keywords

FAQs

Package last updated on 14 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc