This documentation refers to the Graph Search problem. Your solution class will automatically extend GraphSearchSolution, and must override the following functions:
Your script should evaluate to the prototype of your defined class.
The constructor of the GraphSearchSolution class provides the graph to you, you can use it to do preprocessing or simply store it as an instance variable.
This function declares the successful completion of the algorithm.
This function declares the unsuccessful completion of the algorithm.
This will mark a node as expanded in the graphical interface
This will mark a node as visited in the graphical interface
This allows you to display some value without advancing the algorithm
This will highlight the given components in the graphical interface
This is an advanced way to interact with the properties of components
It allows you to alter any settable property of a component as part of the algorithm.
This allows you to iterate over all nodes which are accessible from one given node.
Note: if multiple traversable edges connect the nodes, the generator will generate duplicate entries.
This allows you to iterate over all edges that originate from a given node.
Note: if multiple traversable edges connect the nodes, the generator will generate duplicate entries, with potentially differing weights.
If includeUntraversable
is set to true
, the result will include edges (including virtual edges) which cannot be traversed.
Functions just like getAdjacentNodes, but uses reversed edges.
In practice, this means one obtains the nodes that can directly reach the given node, as opposed to the reciprocal case.
Functions just like getAdjacentEdges, but uses reversed edges.
In practice, this means one obtains the edges whose target is the given node, as opposed to the source.
This allows you to get a reference to any node in the graph by its string ID.
This allows you to get a reference to any edge in the graph by its numeric ID.
This function will return the first edge found that goes from the source to the target, and which is traversable (unless includeUntraversable is true).
If no such edge exists, it will return undefined instead.
This function will yield all edges that go from the source to the target, and which are traversable (unless includeUntraversable is true).
This function returns all edges in the graph, note that this includes edges which may be virtual or untraversable.
You can use the edge's isRef property or its traversable() function to check if it is a virtual edge or untraversable respectively.
The Node is the most basic element in the graph, every node has an id which uniquely identifies it.
The unique identifier of this node in the graph.
A reference to the graph that contains this node.
For grid graphs, the 0-indexed x coordinate of this node.
For grid graphs, the 0-indexed y coordinate of this node.
Arbitrary data stored in this node. Grid graphs guarantee a key named traversable, which is false only if the node is a wall in the grid graph.
You may use this field to store data in the graph. Note that it must be serializable, so you should avoid cyclical data.
Edges are slightly complicated, but very powerful! Edges always have a mirrored version which we will call a virtual edge.
Edges connect pairs of nodes. For bidirectional edges, both the regular and virtual edges are traversable. For directed edges, only the regular edge is traversable, but a virtual edge still exists! This can help you identify the in-degree of a node for directed graphs.
Edges provide a series of helpful properties and functions that should allow you to use them effectively.
A unique numeric ID for this edge. Read-only.
The source of this edge, that is, the node to which it adds an out-degree.
In the case of bidirectional edges, the source is arbitrary
In the case of flipped edges, the source and target are swapped.
The target of this edge, that is, the node to which it adds an in-degree.
In the case of bidirectional edges, the source is arbitrary
In the case of flipped edges, the source and target are swapped.
The weight associated with this edge. For bidirectional edges, it is the same in both directions.
If you wish to simulate a bidirectional edge with different weights, use two directed edges instead. (Useful for case editing)
Indicates whether this edge is bidirectional. Read-only.
Indicates whether this edge is virtual. Read-only.
Arbitrary data stored in this edge.
Notably, data stores some critical information about the edge, such as whether it is flipped.
You may use this field to store data in the graph. Note that it must be serializable, so you should avoid cyclical data. Use IDs to refer to nodes or edges..
This tells you whether an edge is traversable from source to target.
This function allows you to obtain the mirror of an edge. For regular edges, this returns the virtual edge. For virtual edges, this returns a regular edge.