Show / Hide Table of Contents

Class DepthFirstSearchAlgorithm<TVertex, TEdge>

A depth first search algorithm for directed graph.

Inheritance
System.Object
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>
DepthFirstSearchAlgorithm<TVertex, TEdge>
Implements
IAlgorithm<IVertexListGraph<TVertex, TEdge>>
IComputation
IAlgorithmComponent
IDistanceRecorderAlgorithm<TVertex>
IVertexColorizerAlgorithm<TVertex>
IVertexPredecessorRecorderAlgorithm<TVertex, TEdge>
ITreeBuilderAlgorithm<TVertex, TEdge>
IVertexTimeStamperAlgorithm<TVertex>
Inherited Members
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.TryGetRootVertex(TVertex)
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.SetRootVertex(TVertex)
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.ClearRootVertex()
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.RootVertexChanged
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.OnRootVertexChanged(EventArgs)
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.GetAndAssertRootInGraph()
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.AssertRootInGraph(TVertex)
RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>.Compute(TVertex)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.SyncRoot
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.State
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Compute()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Abort()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.StateChanged
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.OnStateChanged(EventArgs)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Started
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.OnStarted(EventArgs)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Finished
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.OnFinished(EventArgs)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Aborted
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.OnAborted(EventArgs)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.VisitedGraph
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Services
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.GetService<T>()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.TryGetService<T>(T)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.TryGetService(Type, Object)
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.ThrowIfCancellationRequested()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Initialize()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.InternalCompute()
AlgorithmBase<IVertexListGraph<TVertex, TEdge>>.Clean()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: QuikGraph.Algorithms.Search
Assembly: QuikGraph.dll
Syntax
public sealed class DepthFirstSearchAlgorithm<TVertex, TEdge> : RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>, IAlgorithm<IVertexListGraph<TVertex, TEdge>>, IComputation, IAlgorithmComponent, IDistanceRecorderAlgorithm<TVertex>, IVertexColorizerAlgorithm<TVertex>, IVertexPredecessorRecorderAlgorithm<TVertex, TEdge>, ITreeBuilderAlgorithm<TVertex, TEdge>, IVertexTimeStamperAlgorithm<TVertex> where TEdge : IEdge<TVertex>
Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Constructors

| Improve this Doc View Source

DepthFirstSearchAlgorithm(IAlgorithmComponent, IVertexListGraph<TVertex, TEdge>)

Initializes a new instance of the DepthFirstSearchAlgorithm<TVertex, TEdge> class.

Declaration
public DepthFirstSearchAlgorithm(IAlgorithmComponent host, IVertexListGraph<TVertex, TEdge> visitedGraph)
Parameters
Type Name Description
IAlgorithmComponent host

Host to use if set, otherwise use this reference.

IVertexListGraph<TVertex, TEdge> visitedGraph

Graph to visit.

Exceptions
Type Condition
System.ArgumentNullException

visitedGraph is null.

| Improve this Doc View Source

DepthFirstSearchAlgorithm(IAlgorithmComponent, IVertexListGraph<TVertex, TEdge>, IDictionary<TVertex, GraphColor>)

Initializes a new instance of the DepthFirstSearchAlgorithm<TVertex, TEdge> class.

Declaration
public DepthFirstSearchAlgorithm(IAlgorithmComponent host, IVertexListGraph<TVertex, TEdge> visitedGraph, IDictionary<TVertex, GraphColor> verticesColors)
Parameters
Type Name Description
IAlgorithmComponent host

Host to use if set, otherwise use this reference.

IVertexListGraph<TVertex, TEdge> visitedGraph

Graph to visit.

System.Collections.Generic.IDictionary<TVertex, GraphColor> verticesColors

Vertices associated to their colors (treatment states).

Exceptions
Type Condition
System.ArgumentNullException

visitedGraph is null.

System.ArgumentNullException

verticesColors is null.

| Improve this Doc View Source

DepthFirstSearchAlgorithm(IAlgorithmComponent, IVertexListGraph<TVertex, TEdge>, IDictionary<TVertex, GraphColor>, Func<IEnumerable<TEdge>, IEnumerable<TEdge>>)

Initializes a new instance of the DepthFirstSearchAlgorithm<TVertex, TEdge> class.

Declaration
public DepthFirstSearchAlgorithm(IAlgorithmComponent host, IVertexListGraph<TVertex, TEdge> visitedGraph, IDictionary<TVertex, GraphColor> verticesColors, Func<IEnumerable<TEdge>, IEnumerable<TEdge>> outEdgesFilter)
Parameters
Type Name Description
IAlgorithmComponent host

Host to use if set, otherwise use this reference.

IVertexListGraph<TVertex, TEdge> visitedGraph

Graph to visit.

System.Collections.Generic.IDictionary<TVertex, GraphColor> verticesColors

Vertices associated to their colors (treatment states).

System.Func<System.Collections.Generic.IEnumerable<TEdge>, System.Collections.Generic.IEnumerable<TEdge>> outEdgesFilter

Delegate that takes the enumeration of out-edges and filters/reorders them. All vertices passed to the method should be enumerated once and only once.

Exceptions
Type Condition
System.ArgumentNullException

visitedGraph is null.

System.ArgumentNullException

verticesColors is null.

System.ArgumentNullException

outEdgesFilter is null.

| Improve this Doc View Source

DepthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge>)

Initializes a new instance of the DepthFirstSearchAlgorithm<TVertex, TEdge> class.

Declaration
public DepthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge> visitedGraph)
Parameters
Type Name Description
IVertexListGraph<TVertex, TEdge> visitedGraph

Graph to visit.

Exceptions
Type Condition
System.ArgumentNullException

visitedGraph is null.

| Improve this Doc View Source

DepthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge>, IDictionary<TVertex, GraphColor>)

Initializes a new instance of the DepthFirstSearchAlgorithm<TVertex, TEdge> class.

Declaration
public DepthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge> visitedGraph, IDictionary<TVertex, GraphColor> verticesColors)
Parameters
Type Name Description
IVertexListGraph<TVertex, TEdge> visitedGraph

Graph to visit.

System.Collections.Generic.IDictionary<TVertex, GraphColor> verticesColors

Vertices associated to their colors (treatment states).

Exceptions
Type Condition
System.ArgumentNullException

visitedGraph is null.

System.ArgumentNullException

verticesColors is null.

Properties

| Improve this Doc View Source

MaxDepth

Gets or sets the maximum exploration depth, from the start vertex.

Declaration
public int MaxDepth { get; set; }
Property Value
Type Description
System.Int32

Maximum exploration depth.

Remarks

Defaulted to int.MaxValue.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Value is negative or equal to 0.

| Improve this Doc View Source

OutEdgesFilter

Filter of edges.

Declaration
public Func<IEnumerable<TEdge>, IEnumerable<TEdge>> OutEdgesFilter { get; }
Property Value
Type Description
System.Func<System.Collections.Generic.IEnumerable<TEdge>, System.Collections.Generic.IEnumerable<TEdge>>
| Improve this Doc View Source

ProcessAllComponents

In case a root vertex has been set, indicates if the algorithm should walk through graph parts of other components than the root component.

Declaration
public bool ProcessAllComponents { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

VerticesColors

Stores vertices associated to their colors (treatment state).

Declaration
public IDictionary<TVertex, GraphColor> VerticesColors { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<TVertex, GraphColor>

Methods

| Improve this Doc View Source

GetVertexColor(TVertex)

Gets the GraphColor associated to the given vertex.

Declaration
public GraphColor GetVertexColor(TVertex vertex)
Parameters
Type Name Description
TVertex vertex

The vertex.

Returns
Type Description
GraphColor

The vertex GraphColor.

Exceptions
Type Condition
System.ArgumentNullException

vertex is null.

VertexNotFoundException

vertex has no associated color.

| Improve this Doc View Source

Initialize()

Called on algorithm initialization step.

Declaration
protected override void Initialize()
Overrides
QuikGraph.Algorithms.AlgorithmBase<QuikGraph.IVertexListGraph<TVertex, TEdge>>.Initialize()
| Improve this Doc View Source

InternalCompute()

Algorithm compute step.

Declaration
protected override void InternalCompute()
Overrides
QuikGraph.Algorithms.AlgorithmBase<QuikGraph.IVertexListGraph<TVertex, TEdge>>.InternalCompute()

Events

| Improve this Doc View Source

BackEdge

Fired when an edge is going to be treated when coming from a gray vertex.

Declaration
public event EdgeAction<TVertex, TEdge> BackEdge
Event Type
Type Description
EdgeAction<TVertex, TEdge>
| Improve this Doc View Source

DiscoverVertex

Fired when a vertex is discovered and under treatment.

Declaration
public event VertexAction<TVertex> DiscoverVertex
Event Type
Type Description
VertexAction<TVertex>
| Improve this Doc View Source

ExamineEdge

Fired when an edge is going to be analyzed.

Declaration
public event EdgeAction<TVertex, TEdge> ExamineEdge
Event Type
Type Description
EdgeAction<TVertex, TEdge>
| Improve this Doc View Source

FinishVertex

An algorithm that exposes events to compute timing with vertices treatment.

Declaration
public event VertexAction<TVertex> FinishVertex
Event Type
Type Description
VertexAction<TVertex>
| Improve this Doc View Source

ForwardOrCrossEdge

Fired when an edge is going to be treated when coming from a black vertex.

Declaration
public event EdgeAction<TVertex, TEdge> ForwardOrCrossEdge
Event Type
Type Description
EdgeAction<TVertex, TEdge>
| Improve this Doc View Source

InitializeVertex

Fired when a vertex is initialized.

Declaration
public event VertexAction<TVertex> InitializeVertex
Event Type
Type Description
VertexAction<TVertex>
| Improve this Doc View Source

StartVertex

Fired on a starting vertex once before the start of the search from it.

Declaration
public event VertexAction<TVertex> StartVertex
Event Type
Type Description
VertexAction<TVertex>
| Improve this Doc View Source

TreeEdge

Fired when an edge is going to be treated when coming from a white vertex.

Declaration
public event EdgeAction<TVertex, TEdge> TreeEdge
Event Type
Type Description
EdgeAction<TVertex, TEdge>

Implements

IAlgorithm<TGraph>
IComputation
IAlgorithmComponent
IDistanceRecorderAlgorithm<TVertex>
IVertexColorizerAlgorithm<TVertex>
IVertexPredecessorRecorderAlgorithm<TVertex, TEdge>
ITreeBuilderAlgorithm<TVertex, TEdge>
IVertexTimeStamperAlgorithm<TVertex>

Extension Methods

GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, String)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, String, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, XmlWriter)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, XmlReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, TextReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, String, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeAndValidateFromGraphML<TVertex, TEdge, TGraph>(TGraph, TextReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
SerializationExtensions.SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String)
SerializationExtensions.SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String, Action<XmlWriter, TGraph>, Action<XmlWriter, TVertex>, Action<XmlWriter, TEdge>)
  • Improve this Doc
  • View Source
In This Article
Back to top QuikGraph