Models the path between two Nodes/Ports, which consists of a series of [Group/Node/Port, Edge] pairs.

Implements

Constructors

  • Parameters

    Returns Path

Properties

toolkit instance from which to get the path info.

Methods

  • Returns true if the path contains the given object (a node, group, port or edge), false otherwise.

    Parameters

    • obj: Edge | Vertex

      Node/Port/Edge, or object id, of the element to test for.

    • Optional doNotFuzzyMatchNodes: boolean

      By default, if you pass a node/group in to this method and the path passes through a port on that node/group, this method returns true. But if you set doNotFuzzyMatchNodes to true, then this method will return true only if the node/group itself is on the path.

    Returns boolean

    True if Path contains the object, false otherwise.

  • Removes all vertices and edges in this path from the underlying Toolkit. This is an alias for deleteVertices, since deleting a vertex causes its edges to also be deleted.

    Returns void

  • Remove all of the edges in this path from the underlying Toolkit instance.

    Returns Path

  • Deletes all the nodes/groups in the path. As with the contains method, there is a special consideration here: if a path passes through ports on a node/group, then that node/group will be, for the purposes of this method, considered to be part of the path and it will be deleted. If you instead wish to delete only the ports in a path, use deletePorts. Note that this method will, of course, have the effect of also deleting all the edges, since the nodes/groups for those edges will no longer exist.

    Returns Path

  • Iterates through the path one step at a time. Each step consists of an object containing a vertex, and, for all entries except the first, an edge member, which supplies the Edge that links to the Vertex (which is why it is null for the first entry).

    Parameters

    • fn: ((i, p) => any)

      Function to call for each step.

        • (i, p): any
        • Parameters

          • i: number
          • p: ShortestPathComponent

          Returns any

    Returns void

  • Iterates through the Edges in the path one step at a time. There is always one fewer Edges than Nodes/Ports.

    Parameters

    • fn: ((i, e) => any)

      Function to call for each step.

        • (i, e): any
        • Parameters

          • i: number
          • e: Edge

          Returns any

    Returns void

  • Iterates through the Groups in the path one step at a time.

    Parameters

    • fn: ((i, g) => void)

      Function to call for each step.

        • (i, g): void
        • Parameters

          • i: number
          • g: Group

          Returns void

    Returns void

  • Iterates through the Nodes in the path one step at a time.

    Parameters

    • fn: ((i, n) => void)

      Function to call for each step.

        • (i, n): void
        • Parameters

          • i: number
          • n: Node

          Returns void

    Returns void

  • Iterates through the Nodes/Groups/Ports in the path one step at a time.

    Parameters

    • fn: ((idx, v) => any)

      Function to call for each step.

        • (idx, v): any
        • Parameters

          • idx: number
          • v: Vertex

          Returns any

    Returns void

  • Returns whether or not a given path exists.

    Returns boolean

    True if path exists, false otherwise.

  • Gets all the edges in the path that are connected to the given vertex.

    Parameters

    • v: Vertex

      Vertex to get edges for.

    Returns Edge[]

  • Gets the cost of the given path. Edges in the Toolkit can have a cost associated with them (the default is 1), and so the cost of any given path is the sum of the cost of all of the edges in the path.

    Returns number

    Total cost of the Path. Null if path does not exist.

  • Gets the Edge at the given index in the Path.

    Parameters

    • idx: number

      Index of the Edge to retrieve. You can use negative numbers here: an index of -1 means get the last edge. An index of -2 means get the last but one. etc.

    Returns Edge

  • Counts the number of edges in the path. This may be zero, if the given path spec did not select a valid path in the Toolkit instance.

    Returns number

  • Gets the Vertex at the given index in the path.

    Parameters

    • idx: number

      Index of the vertex to retrieve.

    Returns Vertex

    vertex at the given index, or null if no vertex exists at the given index.

  • Retrieve the specified vertex from the path

    Parameters

    • obj: string | Vertex

      Either a vertex ID or a node/group/port.

    Returns Vertex

    A Vertex, if the given vertex is in the path, otherwise null.

  • Counts the number of vertices in the Path (including the start and end nodes/groups). Note that for the purposes of this calculation, a Port is considered a vertex, as is a Group.

    Returns number

  • Get all the vertices in the path.

    Returns Vertex[]

  • Returns whether or not a given path is empty

    Returns boolean

    True if path is empty, false otherwise.