Framework class for implementing depth first search (DFS) based algorithms.
Remarks
A depth first search starts from a specified node and traverses the neighbors within a branch as deeply as possible (i.e., without visiting any vertex twice) before backtracking.
A depth first search traversal induces a DFS forest that may consist of more than one DFS tree. Based on these trees, the edges are divided into four categories (see example):
- Tree Edges: The edges of the DFS forest.
- Back edges: Non-tree edges that connect nodes with their ancestors in the DFS tree. Self-loops are also considered as back edges.
- Forward edges: Edges that connect nodes of the DFS tree to one of their descendants.
- Cross edges: All other edges.
During a DFS run each node of the graph can be in one of the following states:
- Undiscovered: A node that has not been visited yet.
- Discovered but not finished: A node that has been already visited, but has not been completed yet, i.e. it is still part of an active path of the DFS tree.
- Finished: A node that has been completed, i.e. it has been visited before and is not part of an active path of the DFS tree anymore.
Graph algorithms, which are based on a depth first search, can extend this class and override appropriate callback methods provided by this class.
Default Values of Properties
directedMode | false | Graphs are considered undirected. |
lookFurtherMode | true |
Type Details
- yfiles module
- algorithms
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.algorithms.Dfs
See Also
Constructors
Creates a new DfsAlgorithm instance with default settings.
Properties
Methods
Callback method that will be invoked whenever DFS continues its search at a new root node.
Remarks
Parameters
A map of options to pass to the method.
- v - YNode
- the new root node
Callback method that will be invoked after the DFS has returned from the given node.
Callback method that will be invoked whenever a node visit has been completed.
Remarks
Parameters
A map of options to pass to the method.
- node - YNode
- the given node
- dfsNumber - number
- the DFS number of the given node
- compNumber - number
- the completion number of the given node
Callback method that will be invoked if the given edge will be considered the first (and only) time during the DFS.
Remarks
Parameters
A map of options to pass to the method.
Callback method that will be invoked whenever a formerly unvisited node gets visited for the first time.
Remarks
Parameters
A map of options to pass to the method.
- node - YNode
- the given node
- dfsNumber - number
- the DFS number of the given node
Fields
Constants
A constant indicating a node has been completed.
Remarks
A constant indicating a node has already been visited, but has not been completed yet.
Remarks
A constant indicating a node has not been visited yet.