npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

concept-network

v2.0.0

Published

Concept Network is weighted directed graph, in which activation values are propagated.

Downloads

28

Readme

concept-network Build Status codecov coverage NPM version

Concept Network is weighted directed graph, in which activation values are propagated. Written in Node.js.

Getting Started

Install the module with: npm install concept-network

import { cnAddNode, cnAddLink } from 'concept-network/lib/concept-network';
import { cnsActivate, cnsPropagate } from 'concept-network/lib/concept-network-state';

let cn = cnAddNode({}, 'ECTOR');
cn = cnAddNode(cn, 'knows');
cn = cnAddNode(cn, 'Achille');

cn = cnAddLink(cn, 'ECTOR', 'knows');
cn = cnAddLink(cn, 'knows', 'Achille');

let cns = cnsActivate({}, 'ECTOR');
cns = cnsPropagate(cn, cns);

which gives:

{ ECTOR: { value: 59.500004166625004, age: 1, old: 100 },
  knows: { value: 63.40844023393148, old: 0, age: 0 } }

Functions

Table of Contents

cnsActivate

Set the activation value of the node which label is given to 100.

Parameters

  • cns ConceptNetworkState
  • label string

Returns ConceptNetworkState

cnsGetActivationValue

Get the activation value of a node (which label is given)

Parameters

  • cns ConceptNetworkState
  • label string

Returns (number | undefined)

cnsGetOldActivationValue

Get the activation value of a node (which label is given)

Parameters

  • cns ConceptNetworkState
  • label string

Returns (number | undefined)

cnsGetMaxActivationValue

Get the maximum activation value of all nodes which label start with beginning.

Parameters

  • cns ConceptNetworkState
  • beginning string (optional, default '')

Returns number

cnsGetActivatedTypedNodes

Return an object associating nodes labels with their activation values, but only for labels starting with beginning and activation values greater or equal to threshold.

Parameters

  • cns ConceptNetworkState
  • beginning string (optional, default '')
  • threshold number (optional, default 95)

cnsSetActivationValue

Set the activation value of a node label.

Parameters

  • cns ConceptNetworkState (optional, default {})
  • label string
  • value number

Returns ConceptNetworkState

cnsPropagate

Propagate the activation values along the links.

Parameters

  • cn ConceptNetwork
  • cns ConceptNetworkState
  • options (optional, default {decay:40,memoryPerf:100})

Returns ConceptNetworkState

cnAddNode

Create a node in cn or increment its occurrence.

Parameters

Returns ConceptNetwork the new ConceptNetwork

cnDecrementNode

Decrement the occ of the node which label is given by one.

Parameters

Returns ConceptNetwork the new ConceptNetwork

cnRemoveNode

Remove the node which label is given (and the links to it)

Parameters

Returns ConceptNetwork the new ConceptNetwork

cnAddLink

Create a link between from and to, and increment coOcc by one.

Parameters

Returns ConceptNetwork the new ConceptNetwork

cnRemoveLink

Remove the link from from to to

Parameters

  • cn ConceptNetwork
  • from string label of the outgoing node
  • to string label of the ingoing node

Returns ConceptNetwork the new ConceptNetwork

cnRemoveLinksOfNode

Remove all links of the node which label is given.

Parameters

  • cn ConceptNetwork
  • label string label of the node which links are to be removed

Returns ConceptNetwork new ConceptNetwork

cnDecrementLink

Decrement the coOcc of the link from from to to by one.

Parameters

  • cn ConceptNetwork
  • from string label of the from node
  • to string label of the to node

Returns ConceptNetwork new ConceptNetwork

cnGetNode

Get the node matching label.

Parameters

  • cn ConceptNetwork
  • label string label of the node to get

Returns (ConceptNetworkNode | undefined)

cnGetLink

Get the link from from to to.

Parameters

  • cn ConceptNetwork
  • from string label of the node from
  • to string label of the node to

Returns (ConceptNetworkLink | undefined)

cnGetLinksFrom

Get the links from label node.

Parameters

  • cn ConceptNetwork
  • label string label of the node from

Returns Array<ConceptNetworkLink>

cnGetLinksTo

Get the links to label node.

Parameters

  • cn ConceptNetwork
  • label string label of the node to

Returns Array<ConceptNetworkLink>

cnGetNodeIndex

Get the index of the node matching label.

Parameters

  • cn ConceptNetwork
  • label string label of the node to get

Returns number -1 when not found

cnGetLinkIndex

Get the index of the link from from to to.

Parameters

  • cn ConceptNetwork
  • from string label of the node from
  • to string label of the node to

Returns number -1 when not found

cnGetLinkIndex2

Get the index of the link from fromIndex to toIndex.

Parameters

  • cn ConceptNetwork
  • fromIndex number label of the node from
  • toIndex number label of the node to

Returns number -1 when not found

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint, and test your code using npm test.

Release History

See also Releases

  • 2019/01/04: version 2.0.0: Change all API to something more functional
  • 2018/12/27: version 1.2.2: Go back to synchronous ConceptNetwork
  • 2015/11/28: version 1.2.1: Update dependencies versions
  • 2015/02/20: version 1.2.0: Add options to propagate()
  • 2015/02/07: version 1.1.0: Make getLink accept two parameters
  • 2015/02/07: version 1.0.0: Go to semantic versioning, add increments to addLink and addNode
  • 2014/08/07: version 0.1.4: fix some error cases with injector
  • 2013/01/05: version 0.1.3: add ConceptNetworkState.getMaximumValue() and ConceptNetworkState.getActivatedTypedNodes()
  • 2013/01/03: version 0.1.2: add ConceptNetworkState

Warning: this is a work in progress.

License

Copyright (c) 2012 François Parmentier Licensed under the MIT license.