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

connected-domain

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connected-domain

calculate all the connected domains based on the given two-dimensional array

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
109K
increased by16.25%
Maintainers
1
Weekly downloads
 
Created
Source

connected-domain

Calculate all the connected domains based on the given two-dimensional array

How To Use

variable samples in the following code is a two-dimensional array parsed from file separate.txt

var ConnectedDomain = require( 'connected-domain' );
var samples = [ ... ];

console.log( ConnectedDomain( samples, function( value ){
    return value;
});

Details

ConnectedDomain( twoDimensionalArray, indicator, ifHardLink ):

  • twoDimensionalArray: A two-dimensional array for ConnectedDomain to parse
  • indicator: Function to decide what identifier each point should have to decide which domain it belongs to. The first parameter will be given as the point value. The return value of this function will be used as the identifier.
  • ifHardLink: Boolean. If use hard-link to decide connected domains. ( see section Hard Link for details )

The result of invocation of ConnectedDomain is a object:

{
    domains: [ {}, {}, ... ],
    totalDomains: 10,
    groupByIdentifier: {
        id1: {},
        id2: {},
        ...
    },
    totalIdentifiers: 5
}

The structure of every domain:

{ 
    bounding: { 
        w: 12, 
        h: 19, 
        x: 0, 
        y: 1
    }, 
    points: [ { x: 1, y: 2, value: 'a' }, {}, ... ], 
    identifier: 'blue', 
    domainId: 1 
} 

ConnectedDomains use soft-link as default. Below is how soft-link think two domains are connected( all the 0 zones are connected as a domain ):

0011
0011
1100
1100

If you use hard-link, the upper-left and bottom-right "0" zones are not connected, they become 2 separate domains. Below shows how a hard-link connection can be formed:

0011
0001
1000
1100

Keywords

FAQs

Package last updated on 23 Apr 2016

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