Concept Network is weighted directed graph, in which activation values are propagated. Written in Node.js.
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 } }
- cnsActivate
- cnsGetActivationValue
- cnsGetOldActivationValue
- cnsGetMaxActivationValue
- cnsGetActivatedTypedNodes
- cnsSetActivationValue
- cnsPropagate
- cnAddNode
- cnDecrementNode
- cnRemoveNode
- cnAddLink
- cnRemoveLink
- cnRemoveLinksOfNode
- cnDecrementLink
- cnGetNode
- cnGetLink
- cnGetLinksFrom
- cnGetLinksTo
- cnGetNodeIndex
- cnGetLinkIndex
- cnGetLinkIndex2
Set the activation value of the node which label
is given to 100.
cns
ConceptNetworkStatelabel
string
Returns ConceptNetworkState
Get the activation value of a node (which label
is given)
cns
ConceptNetworkStatelabel
string
Get the activation value of a node (which label
is given)
cns
ConceptNetworkStatelabel
string
Get the maximum activation value of all nodes which label start with
beginning
.
cns
ConceptNetworkStatebeginning
string (optional, default''
)
Returns number
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
.
cns
ConceptNetworkStatebeginning
string (optional, default''
)threshold
number (optional, default95
)
Set the activation value
of a node label
.
Returns ConceptNetworkState
Propagate the activation values along the links.
cn
ConceptNetworkcns
ConceptNetworkStateoptions
(optional, default{decay:40,memoryPerf:100}
)
Returns ConceptNetworkState
Create a node in cn
or increment its occurrence.
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
Decrement the occ
of the node which label
is given by one.
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
Remove the node which label
is given (and the links to it)
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
Create a link between from
and to
, and increment coOcc
by one.
Returns ConceptNetwork the new ConceptNetwork
Remove the link from from
to to
Returns ConceptNetwork the new ConceptNetwork
Remove all links of the node which label
is given.
cn
ConceptNetworklabel
string label of the node which links are to be removed
Returns ConceptNetwork new ConceptNetwork
Decrement the coOcc of the link from from
to to
by one.
Returns ConceptNetwork new ConceptNetwork
Get the node matching label
.
cn
ConceptNetworklabel
string label of the node to get
Returns (ConceptNetworkNode | undefined)
Get the link from from
to to
.
Returns (ConceptNetworkLink | undefined)
Get the links from label
node.
cn
ConceptNetworklabel
string label of the node from
Returns Array<ConceptNetworkLink>
Get the links to label
node.
cn
ConceptNetworklabel
string label of the node to
Returns Array<ConceptNetworkLink>
Get the index of the node matching label
.
cn
ConceptNetworklabel
string label of the node to get
Returns number -1 when not found
Get the index of the link from from
to to
.
Returns number -1 when not found
Get the index of the link from fromIndex
to toIndex
.
Returns number -1 when not found
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
.
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.
Copyright (c) 2012 François Parmentier Licensed under the MIT license.