grim/entities

Types

EntityOid = string
  Source Edit
Direction {...}{.pure.} = enum
  In, Out, OutIn
  Source Edit
Edge = ref object
  oid*: EntityOid
  label*: string
  startsAt*: Node
  endsAt*: Node
  data: Table[string, Box]
  Source Edit
Node = ref object
  oid*: EntityOid
  label*: string
  data: Table[string, Box]
  incoming: Table[EntityOid, Table[EntityOid, Edge]]
  outgoing: Table[EntityOid, Table[EntityOid, Edge]]
  Source Edit

Procs

proc len[T: Node | Edge](entity: T): int
Return number of data of node or edge   Source Edit
proc `$`(n: Node): string {...}{.raises: [ValueError], tags: [].}
Pretty-print Node   Source Edit
proc `$`(e: Edge): string {...}{.raises: [ValueError], tags: [].}
Pretty-print Edge   Source Edit
proc describe(e: Edge; lineWidth: int = 100; propertyWidth: int = 20): string {...}{.
    raises: [ValueError], tags: [].}
Return a nice pretty-printed summary of edge e   Source Edit
proc describe(n: Node; lineWidth: int = 100; propertyWidth: int = 20): string {...}{.
    raises: [ValueError], tags: [].}
Return a nice pretty-printed summary of node n   Source Edit
proc toMap[T: Node | Edge](entity: T): Map
Convert entity data to Map object.   Source Edit
proc newNode(label: string; data: Table[string, Box] = initTable();
             oid: string = $genOid()): Node {...}{.raises: [], tags: [].}
Create a new node   Source Edit
proc newEdge(A: Node; B: Node; label: string;
             data: Table[string, Box] = initTable(); oid: string = $genOid()): Edge {...}{.
    raises: [], tags: [].}
Create a new edge   Source Edit
proc delete(e: Edge) {...}{.raises: [KeyError], tags: [].}
Delete an edge   Source Edit
proc `==`(self, other: Node): bool {...}{.raises: [], tags: [].}
Check if two Nodes are equal   Source Edit
proc `==`(self, other: Edge): bool {...}{.raises: [], tags: [].}
Check if two Edges are equal   Source Edit
proc `[]`(node: Node; property: string): Box {...}{.raises: [KeyError], tags: [].}
Get property of node   Source Edit
proc `[]=`(node: Node; property: string; value: Box) {...}{.raises: [], tags: [].}
Set property of node to value   Source Edit
proc `[]`(edge: Edge; property: string): Box {...}{.raises: [KeyError], tags: [].}
Get property of edge   Source Edit
proc `[]=`(edge: Edge; property: string; value: Box) {...}{.raises: [], tags: [].}
Set property of edge to value   Source Edit
proc numberOfNeighbors(n: Node; direction: Direction = Direction.Out): int {...}{.
    raises: [KeyError], tags: [].}
Return the number of neighbors of node n in direction.   Source Edit
proc update[T](self: T; p: Table[string, Box]): string
Update node or edge data   Source Edit
proc neighbors(n: Node; direction: Direction = Direction.Out): (
    iterator (): string) {...}{.raises: [KeyError], tags: [].}
Return neighbors to n counting edges with direction.   Source Edit
proc edges(n: Node; direction: Direction = Direction.Out): (iterator (): Edge) {...}{.
    raises: [KeyError], tags: [].}
Iterator over node edges, counting edges with direction.   Source Edit
proc between(A, B: Node; direction: Direction = Direction.Out): (
    iterator (): Edge) {...}{.raises: [KeyError], tags: [].}
Iterator for all edges between nodes A and B in direction.   Source Edit
proc connected(A, B: Node; direction: Direction = Direction.Out): bool {...}{.
    raises: [KeyError], tags: [].}
Check if first and second node is connected with an edge.   Source Edit

Iterators

iterator pairs[T: Node | Edge](obj: T): (string, Box) {...}{.closure.}
Iterate over property pairs   Source Edit
iterator keys[T: Node | Edge](obj: T): string {...}{.closure.}
Iterate over property keys   Source Edit
iterator values[T: Node | Edge](obj: T): Box {...}{.closure.}
Iterate over property values   Source Edit

Templates

template `.`(map: Map; entry: untyped): untyped
Access entities by dot notation   Source Edit