concept-network v2.0.0
concept-network

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
- cnsGetActivationValue
- cnsGetOldActivationValue
- cnsGetMaxActivationValue
- cnsGetActivatedTypedNodes
- cnsSetActivationValue
- cnsPropagate
- cnAddNode
- cnDecrementNode
- cnRemoveNode
- cnAddLink
- cnRemoveLink
- cnRemoveLinksOfNode
- cnDecrementLink
- cnGetNode
- cnGetLink
- cnGetLinksFrom
- cnGetLinksTo
- cnGetNodeIndex
- cnGetLinkIndex
- cnGetLinkIndex2
cnsActivate
Set the activation value of the node which label is given to 100.
Parameters
cnsConceptNetworkStatelabelstring
Returns ConceptNetworkState
cnsGetActivationValue
Get the activation value of a node (which label is given)
Parameters
cnsConceptNetworkStatelabelstring
cnsGetOldActivationValue
Get the activation value of a node (which label is given)
Parameters
cnsConceptNetworkStatelabelstring
cnsGetMaxActivationValue
Get the maximum activation value of all nodes which label start with
beginning.
Parameters
cnsConceptNetworkStatebeginningstring (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
cnsConceptNetworkStatebeginningstring (optional, default'')thresholdnumber (optional, default95)
cnsSetActivationValue
Set the activation value of a node label.
Parameters
Returns ConceptNetworkState
cnsPropagate
Propagate the activation values along the links.
Parameters
cnConceptNetworkcnsConceptNetworkStateoptions(optional, default{decay:40,memoryPerf:100})
Returns ConceptNetworkState
cnAddNode
Create a node in cn or increment its occurrence.
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
cnDecrementNode
Decrement the occ of the node which label is given by one.
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
cnRemoveNode
Remove the node which label is given (and the links to it)
Parameters
cnConceptNetworklabelstring
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
Returns ConceptNetwork the new ConceptNetwork
cnRemoveLinksOfNode
Remove all links of the node which label is given.
Parameters
cnConceptNetworklabelstring 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
Returns ConceptNetwork new ConceptNetwork
cnGetNode
Get the node matching label.
Parameters
cnConceptNetworklabelstring label of the node to get
Returns (ConceptNetworkNode | undefined)
cnGetLink
Get the link from from to to.
Parameters
Returns (ConceptNetworkLink | undefined)
cnGetLinksFrom
Get the links from label node.
Parameters
cnConceptNetworklabelstring label of the node from
Returns Array<ConceptNetworkLink>
cnGetLinksTo
Get the links to label node.
Parameters
cnConceptNetworklabelstring label of the node to
Returns Array<ConceptNetworkLink>
cnGetNodeIndex
Get the index of the node matching label.
Parameters
cnConceptNetworklabelstring label of the node to get
Returns number -1 when not found
cnGetLinkIndex
Get the index of the link from from to to.
Parameters
Returns number -1 when not found
cnGetLinkIndex2
Get the index of the link from fromIndex to toIndex.
Parameters
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.