grim/graph

Types

Graph = ref object
  name*: string
  nodeTable: Table[EntityOid, Node]
  edgeTable: Table[EntityOid, Edge]
  nodeIndex: Table[string, Table[EntityOid, Node]]
  edgeIndex: Table[string, Table[EntityOid, Edge]]
  Source Edit

Procs

proc numberOfNodes(self: Graph): int {...}{.raises: [], tags: [].}
Return number of Nodes in Graph   Source Edit
proc numberOfEdges(self: Graph): int {...}{.raises: [], tags: [].}
Return number of Edges in Graph   Source Edit
proc nodeLabels(self: Graph): seq[string] {...}{.raises: [], tags: [].}
Return all node labels in the graph   Source Edit
proc edgeLabels(self: Graph): seq[string] {...}{.raises: [], tags: [].}
Return all edge labels in the graph   Source Edit
proc `$`(self: Graph): string {...}{.raises: [ValueError], tags: [].}
Pretty-print Graph   Source Edit
proc contains(self: Graph; key: string): bool {...}{.raises: [], tags: [].}
Check if Node or Edge oid is in Graph   Source Edit
proc contains(self: Graph; key: Node): bool {...}{.raises: [], tags: [].}
Check if Node object is in Graph   Source Edit
proc contains(self: Graph; key: Edge): bool {...}{.raises: [], tags: [].}
Check if Edge object is in Graph   Source Edit
proc newGraph(name: string = "graph"): Graph {...}{.raises: [], tags: [].}
Create a new graph   Source Edit
proc addNode(self: Graph; label: string; data: Table[string, Box] = initTable();
             oid: string = $genOid()): string {...}{.raises: [], tags: [].}
Add node to graph.   Source Edit
proc addNode(self: Graph; n: Node): string {...}{.raises: [], tags: [].}
Add node to graph.   Source Edit
proc addEdge(self: Graph; e: Edge): string {...}{.raises: [], tags: [].}
Add edge to graph.   Source Edit
proc addEdge(self: Graph; A: Node; B: Node; label: string;
             data: Table[string, Box] = initTable(); oid: string = $genOid()): string {...}{.
    raises: [], tags: [].}
Add edge to graph   Source Edit
proc addEdge(self: Graph; A: string; B: string; label: string;
             data: Table[string, Box] = initTable(); oid: string = $genOid()): string {...}{.
    raises: [KeyError], tags: [].}
Add edge to graph.   Source Edit
proc node(self: Graph; node: string): Node {...}{.raises: [KeyError], tags: [].}
Return node with oid in graph   Source Edit
proc edge(self: Graph; edge: string): Edge {...}{.raises: [KeyError], tags: [].}
Return edge with oid in graph   Source Edit
proc hasEdge(self: Graph; A: string; B: string;
             direction: Direction = Direction.Out): bool {...}{.raises: [KeyError],
    tags: [].}
Check if there is an edge between nodes A and B in direction in the graph.   Source Edit
proc delEdge(self: Graph; oid: string): bool {...}{.raises: [KeyError], tags: [].}
Delete edge with oid in graph, return true if edge was in graph and false otherwise.   Source Edit
proc delNode(self: Graph; oid: string): bool {...}{.raises: [Exception, KeyError],
    tags: [RootEffect].}
Delete node with oid in graph, return true if node was in graph and false otherwise.   Source Edit
proc describe(g: Graph; lineWidth = 100): string {...}{.
    raises: [KeyError, ValueError], tags: [].}
Return a nice pretty-printed summary of the graph g   Source Edit
proc navigate(g: Graph; anchor: string): PathCollection {...}{.raises: [KeyError],
    tags: [].}
Navigate paths by pattern matching in graph   Source Edit

Templates

template nodes(self: Graph; labels: untyped = newSeq[string]();
               filter: untyped = true): (iterator (): Node)
Return iterator for nodes with labels in graph, conditioned on filter.   Source Edit
template edges(self: Graph; labels: untyped = newSeq[string]();
               filter: untyped = true): (iterator (): Edge)
Return iterator for edges with labels in graph, conditioned on filter.   Source Edit
template neighbors(self: Graph; oid: string; filter: untyped = true;
                   direction: Direction = Direction.Out): (iterator (): string)
Return neighbors to node oid in graph g, in direction, conditioned on filter.   Source Edit
template edgesBetween(self: Graph; A: string; B: string; filter: untyped = true;
                      direction: Direction = Direction.Out): (iterator (): Edge)
Iterator for all edges between nodes A and B in direction, conditioned on filter.   Source Edit