Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Path

Both .Morphism() and .Vertex() create path objects, which provide the following traversal methods. Note that .Vertex() returns a query object, which is a subclass of path object.

For these examples, suppose we have the following graph:

+-------+                        +------+
| alice |-----                 ->| fred |<--
+-------+     \---->+-------+-/  +------+   \-+-------+
              ----->| #bob# |       |         |*emily*|
+---------+--/  --->+-------+       |         +-------+
| charlie |    /                    v
+---------+   /                  +--------+
  \---    +--------+             |*#greg#*|
      \-->| #dani# |------------>+--------+
          +--------+

Where every link is a <follows> relationship, and the nodes with an extra # in the name have an extra <status> link. As in,

<dani> -- <status> --> "cool_person"

Perhaps these are the influencers in our community. So too are extra *s in the name -- these are our smart people, according to the <smart_graph> label, eg, the quad:

<greg> <status> "smart_person" <smart_graph> .

Hierarchy

  • Path

Index

Constructors

constructor

Properties

globalCalls

globalCalls: Call[]

steps

steps: Step[]
todo

make path to accept type variable of fields

Methods

all

  • Execute the query and adds the results, with all tags, as a string-to-string (tag to node) map in the output set, one for each path that a traversal could take.

    Returns Path

and

as

  • as(...tags: string[]): Path

back

  • back(tag?: string): Path
  • Return current path to a set of nodes on a given tag, preserving all constraints. If still valid, a path will now consider their vertex to be the same one as the previously tagged one, with the added constraint that it was valid all the way here. Useful for traversing back in queries and taking another route for things that have matched so far.

    Parameters

    • Optional tag: string

    Returns Path

both

  • both(path: Path, ...tags: string[]): Path
  • Follow the predicate in either direction. Same as out or in.

    Parameters

    • path: Path
    • Rest ...tags: string[]

    Returns Path

count

difference

except

  • Removes all paths which match query from current path. In a set-theoretic sense, this is (A - B). While g.V().Except(path) to achieve U - B = !B is supported, it's often very slow.

    Parameters

    Returns Path

filter

  • Apply constraints to a set of nodes. Can be used to filter values by range or match strings.

    Parameters

    Returns Path

follow

  • The way to use a path prepared with Morphism. Applies the path chain on the morphism object to the current path. Starts as if at the g.M() and follows through the morphism path.

    Parameters

    Returns Path

followR

  • The same as follow but follows the chain in the reverse direction. Flips "In" and "Out" where appropriate, the net result being a virtual predicate followed in the reverse direction. Starts at the end of the morphism and follows it backwards (with appropriate flipped directions) to the g.M() location.

    Parameters

    Returns Path

followRecursive

  • The same as follow but follows the chain recursively. Starts as if at the g.M() and follows through the morphism path multiple times, returning all nodes encountered.

    Parameters

    Returns Path

getLimit

  • getLimit(limit: number): Path
  • The same as All, but limited to the first N unique nodes at the end of the path, and each of their possible traversals.

    Parameters

    • limit: number

    Returns Path

has

  • has(predicate: string, object: string): Path
  • Filter all paths which are, at this point, on the subject for the given predicate and object, but do not follow the path, merely filter the possible paths. Usually useful for starting with all nodes, or limiting to a subset depending on some predicate/value pair. /

    Parameters

    • predicate: string
    • object: string

    Returns Path

hasR

  • hasR(predicate: string, object: string): Path
  • The same as Has, but sets constraint in reverse direction.

    Parameters

    • predicate: string
    • object: string

    Returns Path

in

  • in(predicatePath?: Path, ...tags: string[]): Path
  • The inverse of out. Starting with the nodes in path on the object, follow the quads with predicates defined by predicatePath to their subjects.

    • null or undefined: All predicates pointing into this node
    • a string: The predicate name to follow into this node
    • a list of strings: The predicates to follow into this node
    • a query path object: The target of which is a set of predicates to follow.
    • null or undefined: No tags
    • a string: A single tag to add the predicate used to the output set.
    • a list of strings: Multiple tags to use as keys to save the predicate used to the output set.

    Parameters

    • Optional predicatePath: Path
    • Rest ...tags: string[]

    Returns Path

inPredicates

  • inPredicates(): Path

intersect

  • Filter all paths by the result of another query path. This is essentially a join where, at the stage of each path, a node is shared.

    Parameters

    Returns Path

is

  • is(node: string, ...nodes: string[]): Path
  • Filter all paths to ones which, at this point, are on the given node.

    Parameters

    • node: string
    • Rest ...nodes: string[]

    Returns Path

labelContext

  • labelContext(labelPath: Path, ...tags: string[]): Path
  • Set (or remove) the subgraph context to consider in the following traversals. Affects all in(), out(), and both() calls that follow it. The default LabelContext is null (all subgraphs).

    • null or undefined: In future traversals, consider all edges, regardless of subgraph.
    • a string: The name of the subgraph to restrict traversals to.
    • a list of strings: A set of subgraphs to restrict traversals to.
    • a query path object: The target of which is a set of subgraphs.
    • null or undefined: No tags
    • a string: A single tag to add the last traversed label to the output set.
    • a list of strings: Multiple tags to use as keys to save the label used to the output set.

    Parameters

    • labelPath: Path
    • Rest ...tags: string[]

    Returns Path

labels

limit

  • limit(limit: number): Path

or

order

out

  • The work-a-day way to get between nodes, in the forward direction. Starting with the nodes in path on the subject, follow the quads with predicates defined by predicatePath to their objects.

    • null or undefined: All predicates pointing out from this node
    • a string: The predicate name to follow out from this node
    • a list of strings: The predicates to follow out from this node
    • a query path object: The target of which is a set of predicates to follow.
    • null or undefined: No tags
    • a string: A single tag to add the predicate used to the output set.
    • a list of strings: Multiple tags to use as keys to save the predicate used to the output set.

    Parameters

    • Optional predicateOrPath: Call | Call[] | Path
    • Rest ...tags: string[]

    Returns Path

outPredicates

  • outPredicates(): Path

save

  • save(predicate: string, tag: string): Path
  • Save the object of all quads with predicate into tag, without traversal.

    Parameters

    • predicate: string
    • tag: string

    Returns Path

saveInPredicates

  • saveInPredicates(tag: string): Path
  • Tag the list of predicates that are pointing in to a node.

    Parameters

    • tag: string

    Returns Path

saveOpt

  • saveOpt(predicate: string, tag: string): Path
  • The same as save, but returns empty tags if predicate does not exists.

    Parameters

    • predicate: string
    • tag: string

    Returns Path

saveOptR

  • saveOptR(predicate: string, tag: string): Path
  • The same as saveOpt, but tags values via reverse predicate.

    Parameters

    • predicate: string
    • tag: string

    Returns Path

saveOutPredicates

  • saveOutPredicates(tag: string): Path
  • Tag the list of predicates that are pointing out from a node.

    Parameters

    • tag: string

    Returns Path

saveR

  • saveR(predicate: string, tag: string): Path
  • The same as save, but tags values via reverse predicate.

    Parameters

    • predicate: string
    • tag: string

    Returns Path

skip

  • skip(offset: number): Path

tag

  • tag(...tags: string[]): Path
  • Save a list of nodes to a given tag. In order to save your work or learn more about how a path got to the end, we have tags. The simplest thing to do is to add a tag anywhere you'd like to put each node in the result set. /reached "Tag"

    Parameters

    • Rest ...tags: string[]

    Returns Path

tagArray

  • The same as toArray, but instead of a list of top-level nodes, returns an Array of tag-to-string dictionaries, much as All would, except inside the JS environment.

    Returns Path

tagValue

  • The same as TagArray, but limited to one result node. Returns a tag-to-string map.

    Returns Path

toArray

  • Execute a query and returns the results at the end of the query path as an JS array.

    Returns Path

toString

  • toString(): string

toValue

union

  • Return the combined paths of the two queries. Notice that it's per-path, not per-node. Once again, if multiple paths reach the same destination, they might have had different ways of getting there (and different tags). See also: Path.prototype.tag()

    Parameters

    Returns Path

unique

Generated using TypeDoc