Graph

<script src="./point_src/graph-connections"></script>

This graph chain stores one to one relationships, with methods to iterate the chain in two directions. This allows use to grab the standard A -> B -> C, and C -> B -> A.

    // some points
    const head = new Point()
    const points = new PointList(head, ...others)

    // setup connections
    const g = new GraphConnections;

    g.connect(0, 1, 2, 3, 4)
          g.connect(2, 5)
             g.connect(5, 6, 7, 8)

Iterate one-to-one relationships (a depth of 1):

let ps = points
g.forPair((_a, _b)=>{
    followPoint( ps.getById(_a), ps.getById(_b), 50)
}, this.reverse)

Provide a forward function, walking thourhg the chain start from the chosen head:

let head = this.g.head.uuid
let ps = points

let f = (key,fromKey,a)=>{
    followPoint( ps.getById(fromKey), ps.getById(key), 50)
}

g.getForward(head, f)

Manual iteration:

let ps = points
let forwardGraph = g.forward
for(let k in forwardGraph) {
    let v = forwardGraph[k]

    for(let i of v) {
        followPoint(ps[parseInt(k)], ps[parseInt(i)], 50)
    }
}

Capture re-visits for deeper chains.

    const graphChain = function(head, ps) {
        let visits = {}

        let pairCallback = (key, fromKey, allTargets)=>{
            constraints.distance(ps[fromKey], ps[key], 50)

            if(visits[fromKey] == undefined) { visits[fromKey] = 0 }
            if(visits[key] == undefined) { visits[key] = 0 }

            visits[fromKey] += 1
            visits[key] += 1
        }

        g.walkForward(head, pairCallback)
    }

    graphChain(head, points)

The graph can resolve a "star based" configuration:

A      C
  \   /
    B
    |
    D
    |
    E

Each connection is given in a pair, from an origin node (the head)

head = B

B -> C
B -> D [ -> E ]
D -> E
B -> A

Where it's used

The followPoint method allows a point to follow another point, at a distance. This is a lot like constraints but with a one to one relationship in a single direction.

Meta Data
title Graph
dependencies ()
unused_keys ()
unknown_keys ()
filepath_exists True
path graph-connections
filepath graph-connections.js
clean_files ()

  • ClassDeclaration
    class comments:
    neighbours by connections. When reversing; we grab the rear node, and in reverse, we iterate siblings.
    • constructor

      constructor

      (
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      neighbours by connections. When reversing; we grab the rear node, and in reverse, we iterate siblings.
    • method

      connect

      (
      items
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      split an array into overlapping pairs [0,1,2,3,4,5] [0,1] [1,2] [2,3] ...
    • method

      add

      (
      a , b
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Add forward. this builds the following: { "0": [1 ], "1": [0, 2 ], "2": [1, 3, 5], "3": [2, 4], "4": [3 ], "5": [2, 6], "6": [5 ] } For connections, we walk (from a key numer) in a direction, generating pairs. Some keys will fork - but that should generated the connected pair set. e.g, pulling '3', 3 -> 2, 4 4 -> [3] <= not executed, 2 -> 1, [3], 5 <= skip 3, as "2" 1 -> 0, 2 <= skip 2, as "1" ...
    • method

      getChain

      (
      fromId , func
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    • method

      walkForward

      (
      fromId , func , previousId , count , maxCount
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      This is back through the original chain.
    • method

      forPair

      (
      func , reverse
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      if(reverse == true) {
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])
  • ClassDeclaration
    class comments:
    Add forward. this builds the following: { "0": [1 ], "1": [0, 2 ], "2": [1, 3, 5], "3": [2, 4], "4": [3 ], "5": [2, 6], "6": [5 ] } For connections, we walk (from a key numer) in a direction, generating pairs. Some keys will fork - but that should generated the connected pair set. e.g, pulling '3', 3 -> 2, 4 4 -> [3] <= not executed, 2 -> 1, [3], 5 <= skip 3, as "2" 1 -> 0, 2 <= skip 2, as "1" ...
    • method

      add

      (
      a , b
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Add forward. this builds the following: { "0": [1 ], "1": [0, 2 ], "2": [1, 3, 5], "3": [2, 4], "4": [3 ], "5": [2, 6], "6": [5 ] } For connections, we walk (from a key numer) in a direction, generating pairs. Some keys will fork - but that should generated the connected pair set. e.g, pulling '3', 3 -> 2, 4 4 -> [3] <= not executed, 2 -> 1, [3], 5 <= skip 3, as "2" 1 -> 0, 2 <= skip 2, as "1" ...
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])