@ector/concept-network
v1.1.0
Published
Weighted directed graph
Downloads
5
Readme
@ector/concept-network
Concept Network is weighted directed graph, in which activation values can be
propagated, using @ector/state
.
Usage
const conceptNetwork = require('@ector/concept-network');
let cn = conceptNetwork.addNode({}, 'node1');
cn = conceptNetwork.addNode(cn, 'node2');
cn = conceptNetwork.addLink(cn, 'node1', 'node2');
// {
// node: [ { label: 'node1', occ: 1 }, { label: 'node2', occ: 1 } ],
// link: [ { from: 0, to: 1, coOcc: 1 } ]
// }
Functions
Table of Contents
- ConceptNetwork
- ConceptNetworkNode
- ConceptNetworkLink
- getNode
- getNodeIndex
- addNode
- addLink
- getLink
- getLinksFrom
- getLinksTo
- removeNode
- nodes
- removeLinksOfNode
- removeLink
- getLinkIndex
- getLinkIndex2
- decrementNode
- decrementLink
- incrementBeginning
- incrementMiddle
- incrementEnd
ConceptNetwork
Properties
node
Array<ConceptNetworkNode>?link
Array<ConceptNetworkLink>?
ConceptNetworkNode
Properties
label
stringocc
number occurrence of the nodebeg
number? Times at the beginning of a sentencemid
number? Times at the middle of a sentenceend
number? Times at the end of a sentence
ConceptNetworkLink
Properties
from
number incoming node indexto
number outcoming node indexcoOcc
number co-occurrence of both nodes
getNode
Get the node matching label
.
Parameters
cn
ConceptNetworklabel
string label of the node to get
Returns (ConceptNetworkNode | undefined)
getNodeIndex
Get the index of the node matching label
.
Parameters
cn
ConceptNetworklabel
string label of the node to get
Returns number -1 when not found
addNode
Create a node in cn
or increment its occurrence.
Parameters
cn
ConceptNetworklabel
string
addLink
Create a link between from
and to
, and increment coOcc
by one.
Parameters
cn
ConceptNetworkfrom
stringto
string
Returns ConceptNetwork the new ConceptNetwork
getLink
Get the link from from
to to
.
Parameters
cn
ConceptNetworkfrom
string label of the node fromto
string label of the node to
Returns (ConceptNetworkLink | undefined)
getLinksFrom
Get the links from label
node.
Parameters
cn
ConceptNetworklabel
string label of the node from
Returns Array<ConceptNetworkLink>
getLinksTo
Get the links to label
node.
Parameters
cn
ConceptNetworklabel
string label of the node to
Returns Array<ConceptNetworkLink>
removeNode
Remove the node which label
is given (and the links to it)
Parameters
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
nodes
Parameters
nodes
Array<ConceptNetworkNode>node
ConceptNetworkNode
Returns Array<ConceptNetworkNode>
removeLinksOfNode
Remove all links of the node which label
is given.
Parameters
cn
ConceptNetworklabel
string label of the node which links are to be removed
Returns ConceptNetwork new ConceptNetwork
removeLink
Remove the link from from
to to
Parameters
cn
ConceptNetworkfrom
string label of the outgoing nodeto
string label of the ingoing node
Returns ConceptNetwork the new ConceptNetwork
getLinkIndex
Get the index of the link from from
to to
.
Parameters
cn
ConceptNetworkfrom
string label of the node fromto
string label of the node to
Returns number -1 when not found
getLinkIndex2
Get the index of the link from fromIndex
to toIndex
.
Parameters
cn
ConceptNetworkfromIndex
number label of the node fromtoIndex
number label of the node to
Returns number -1 when not found
decrementNode
Decrement the occ
of the node which label
is given by one.
Parameters
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
decrementLink
Decrement the coOcc of the link from from
to to
by one.
Parameters
cn
ConceptNetworkfrom
string label of the from nodeto
string label of the to node
Returns ConceptNetwork new ConceptNetwork
incrementBeginning
Increment the beg
of the node which label
is given by one.
Parameters
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
incrementMiddle
Increment the mid
of the node which label
is given by one.
Parameters
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork
incrementEnd
Increment the end
of the node which label
is given by one.
Parameters
cn
ConceptNetworklabel
string
Returns ConceptNetwork the new ConceptNetwork