@ector/concept-network

Weighted directed graph

Usage no npm install needed!

<script type="module">
  import ectorConceptNetwork from 'https://cdn.skypack.dev/@ector/concept-network';
</script>

README

@ector/concept-network

npm version

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

Type: Object<string, any>

Properties

ConceptNetworkNode

Type: Object<string, any>

Properties

  • label string
  • occ number occurrence of the node
  • beg number? Times at the beginning of a sentence
  • mid number? Times at the middle of a sentence
  • end number? Times at the end of a sentence

ConceptNetworkLink

Type: Object<string, any>

Properties

  • from number incoming node index
  • to number outcoming node index
  • coOcc number co-occurrence of both nodes

getNode

Get the node matching label.

Parameters

Returns (ConceptNetworkNode | undefined)

getNodeIndex

Get the index of the node matching label.

Parameters

Returns number -1 when not found

addNode

Create a node in cn or increment its occurrence.

Parameters

addLink

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

Parameters

Returns ConceptNetwork the new ConceptNetwork

getLink

Get the link from from to to.

Parameters

Returns (ConceptNetworkLink | undefined)

getLinksFrom

Get the links from label node.

Parameters

Returns Array<ConceptNetworkLink>

getLinksTo

Get the links to label node.

Parameters

Returns Array<ConceptNetworkLink>

removeNode

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

Parameters

Returns ConceptNetwork the new ConceptNetwork

nodes

Parameters

Returns Array<ConceptNetworkNode>

removeLinksOfNode

Remove all links of the node which label is given.

Parameters

Returns ConceptNetwork new ConceptNetwork

removeLink

Remove the link from from to to

Parameters

Returns ConceptNetwork the new ConceptNetwork

getLinkIndex

Get the index of the link from from to to.

Parameters

Returns number -1 when not found

getLinkIndex2

Get the index of the link from fromIndex to toIndex.

Parameters

Returns number -1 when not found

decrementNode

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

Parameters

Returns ConceptNetwork the new ConceptNetwork

decrementLink

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

Parameters

Returns ConceptNetwork new ConceptNetwork

incrementBeginning

Increment the beg of the node which label is given by one.

Parameters

Returns ConceptNetwork the new ConceptNetwork

incrementMiddle

Increment the mid of the node which label is given by one.

Parameters

Returns ConceptNetwork the new ConceptNetwork

incrementEnd

Increment the end of the node which label is given by one.

Parameters

Returns ConceptNetwork the new ConceptNetwork