Socket
Socket
Sign inDemoInstall

simplicial-complex

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0 to 0.0.1

2

package.json
{
"name": "simplicial-complex",
"version": "0.0.0",
"version": "0.0.1",
"description": "Topological indexing for simplicial complexes",

@@ -5,0 +5,0 @@ "main": "topology.js",

simplicial-complex
==================
Topological operations and indexing for simplicial complexes (ie graphs, triangular and tetrahedral meshes, etc.) in node.js.
This CommonJS module
Topological operations and indexing for [simplicial complexes](http://en.wikipedia.org/wiki/Simplicial_complex) (ie graphs, triangular and tetrahedral meshes, etc.) in node.js.
Usage
=====
First, you need to install the library using npm:
First, you need to install the library using [npm](https://npmjs.org/):

@@ -17,3 +20,3 @@ npm install simplical-complex

Simplicial complexes are represented as arrays of vertex indices. For example, here is a triangular mesh:
`simplicial-complex` represents cell complexes as arrays of arrays of vertex indices. For example, here is a triangular mesh:

@@ -39,3 +42,3 @@ var tris = [

The functionality `mesh-topology` can be broadly grouped into the following categories:
The functionality in this library can be broadly grouped into the following categories:

@@ -148,3 +151,2 @@ Generic

### `skeleton(cells, n)`

@@ -166,2 +168,12 @@ Computes the [n-skeleton](http://en.wikipedia.org/wiki/N-skeleton) of an unoriented simplicial complex. This is the set of all unique n-cells up to permutation.

### `boundary(cells, n)`
Computes the <a href="http://en.wikipedia.org/wiki/Boundary_(topology)">d-dimensional boundary</a> of a cell complex. For example, in a triangular mesh `boundary(tris, 1)` gives an array of all the boundary edges of the mesh; or `boundary(tets, 2)` gives an array of all boundary faces. Algebraically, this is the same as evaluating the boundary operator in the Z/2 homology.
* `cells` is a cell complex.
* `n` is the dimension of the boundary we are computing.
**Returns:** A `normalize`d array of `n`-dimensional cells representing the boundary of the cell complex.
**Time complexity:** `O((d^n + log(cells.length)) * cells.length)`
### `connectedComponents(cells[, vertex_count])`

@@ -176,22 +188,6 @@ Splits a simplicial complex into its <a href="http://en.wikipedia.org/wiki/Connected_component_(topology)">connected components</a>. If `vertex_count` is specified, we assume that the cell complex is dense -- or in other words the vertices of the cell complex is the set of integers [0, vertex_count). This allows for a slightly more efficient implementation. If unspecified, a more general but less efficient sparse algorithm is used.

**Time complexity:**
* If `vertex_count` is specified: `O(vertex_count + d^2 * cells.length)`
* If `vertex_count` is not specified: `O(d^3 * log(cells.length) * cells.length)`
Homology
--------
### `boundary(cells, n)`
Computes the <a href="http://en.wikipedia.org/wiki/Boundary_(topology)">d-dimensional boundary</a> of a cell complex. For example, in a triangular mesh `boundary(tris, 1)` gives an array of all the boundary edges of the mesh; or `boundary(tets, 2)` gives an array of all boundary faces. Algebraically, this is the same as evaluating the boundary operator in the Z/2 homology.
* `cells` is a cell complex.
* `n` is the dimension of the boundary we are computing.
**Returns:** A `normalize`d array of `n`-dimensional cells representing the boundary of the cell complex.
**Time complexity:** `O((dimension(cells)^d + log(cells.length)) * cells.length)`
### `cycles(cells, n)`
Credits

@@ -198,0 +194,0 @@ =======

@@ -162,8 +162,2 @@ var test = require("tap").test

var from_cells = top.normalize([
[0,1,2],
[0,1,3],
[0,2,3],
[1,2,3]
]);
var to_cells = top.normalize([
[0,1],

@@ -175,2 +169,8 @@ [0,2],

]);
var to_cells = top.normalize([
[0,1,2],
[0,1,3],
[0,2,3],
[1,2,3]
]);

@@ -180,6 +180,9 @@ var index = top.buildIndex(from_cells, to_cells);

console.log(from_cells, to_cells);
for(var i=0; i<from_cells.length; ++i) {
var idx = index[i];
console.log(from_cells[i], idx);
}
t.end();

@@ -189,4 +192,5 @@ });

test("stars", function(t) {
t.end();

@@ -200,3 +204,2 @@ });

test("connectedComponents_sparse", function(t) {
t.end();

@@ -203,0 +206,0 @@ });

@@ -29,3 +29,3 @@ "use strict"; "use restrict";

//Clone cells
//Returns a deep copy of cells
function cloneCells(cells) {

@@ -130,3 +130,3 @@ var ncells = new Array(cells.length);

var c = to_cells[i];
for(var k=1; k<=(1<<c.length); ++k) {
for(var k=1; k<(1<<c.length); ++k) {
b.length = bits.popCount(k);

@@ -145,3 +145,3 @@ var l = 0;

index[idx++].push(i);
if(idx >= from_cells.length || compareCells(from_cells[idx], b) === 0) {
if(idx >= from_cells.length || compareCells(from_cells[idx], b) !== 0) {
break;

@@ -177,2 +177,5 @@ }

function subcells(cells, n) {
if(n < 0) {
return [];
}
var result = []

@@ -199,2 +202,5 @@ , k0 = (1<<(n+1))-1;

function skeleton(cells, n) {
if(n < 0) {
return [];
}
var res = subcells(cells, n);

@@ -222,4 +228,7 @@ normalize(res);

//Computes the boundary operator in the Z/2 homology
//Computes the nth boundary operator
function boundary(cells, n) {
if(n < 0) {
return [];
}
var res = subcells(cells, n);

@@ -247,7 +256,2 @@ res.sort(compareCells);

function cycles(cells, n) {
}
//Computes connected components for a dense cell complex

@@ -319,3 +323,1 @@ function connectedComponents_dense(cells, vertex_count) {

exports.connectedComponents = connectedComponents;
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc