Skip to main content

Home > @jsplumbtoolkit/core > Path

Path class

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


export declare class Path implements FilterableDataset 

Implements: FilterableDataset


(constructor)(toolkit, params)Constructs a new instance of the Path class




contains(obj, doNotFuzzyMatchNodes)Returns true if the path contains the given object (a node, group, port or edge), false otherwise.
deleteAll()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.
deleteEdges()Remove all of the edges in this path from the underlying Toolkit instance.
deleteVertices()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.
each(fn)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).
eachEdge(fn)Iterates through the Edges in the path one step at a time. There is always one fewer Edges than Nodes/Ports.
eachGroup(fn)Iterates through the Groups in the path one step at a time.
eachNode(fn)Iterates through the Nodes in the path one step at a time.
eachVertex(fn)Iterates through the Nodes/Groups/Ports in the path one step at a time.
exists()Returns whether or not a given path exists.
filter(spec, includePartials)
getAllEdgesFor(v)Gets all the edges in the path that are connected to the given vertex.
getCost()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.
getEdgeAt(idx)Gets the Edge at the given index in the Path.
getEdgeCount()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.
getNodeAt(idx)Gets the Vertex at the given index in the path.
getVertex(obj)Retrieve the specified vertex from the path
getVertexCount()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.
getVertices()Get all the vertices in the path.
isEmpty()Returns whether or not a given path is empty