Class BreadthFirstSearchAlgorithm<TVertex, TEdge>
A breath first search algorithm for directed graphs.
Inheritance
Implements
Inherited Members
Namespace: QuikGraph.Algorithms.Search
Assembly: QuikGraph.dll
Syntax
public sealed class BreadthFirstSearchAlgorithm<TVertex, TEdge> : RootedAlgorithmBase<TVertex, IVertexListGraph<TVertex, TEdge>>, IAlgorithm<IVertexListGraph<TVertex, TEdge>>, IComputation, IAlgorithmComponent, IVertexPredecessorRecorderAlgorithm<TVertex, TEdge>, ITreeBuilderAlgorithm<TVertex, TEdge>, IDistanceRecorderAlgorithm<TVertex>, IVertexColorizerAlgorithm<TVertex> where TEdge : IEdge<TVertex>Type Parameters
| Name | Description | 
|---|---|
| TVertex | Vertex type. | 
| TEdge | Edge type. | 
Remarks
This is a modified version of the classic DFS algorithm where the search is performed both in depth and height.
Constructors
| Improve this Doc View SourceBreadthFirstSearchAlgorithm(IAlgorithmComponent, IVertexListGraph<TVertex, TEdge>, IQueue<TVertex>, IDictionary<TVertex, GraphColor>)
Initializes a new instance of the BreadthFirstSearchAlgorithm<TVertex, TEdge> class.
Declaration
public BreadthFirstSearchAlgorithm(IAlgorithmComponent host, IVertexListGraph<TVertex, TEdge> visitedGraph, IQueue<TVertex> vertexQueue, 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. | 
| IQueue<TVertex> | vertexQueue | Queue of vertices to treat. | 
| System.Collections.Generic.IDictionary<TVertex, GraphColor> | verticesColors | Vertices associated to their colors (treatment states). | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
BreadthFirstSearchAlgorithm(IAlgorithmComponent, IVertexListGraph<TVertex, TEdge>, IQueue<TVertex>, IDictionary<TVertex, GraphColor>, Func<IEnumerable<TEdge>, IEnumerable<TEdge>>)
Initializes a new instance of the BreadthFirstSearchAlgorithm<TVertex, TEdge> class.
Declaration
public BreadthFirstSearchAlgorithm(IAlgorithmComponent host, IVertexListGraph<TVertex, TEdge> visitedGraph, IQueue<TVertex> vertexQueue, 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. | 
| IQueue<TVertex> | vertexQueue | Queue of vertices to treat. | 
| 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 | Function that is used filter out-edges of a vertex. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
BreadthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge>)
Initializes a new instance of the BreadthFirstSearchAlgorithm<TVertex, TEdge> class.
Declaration
public BreadthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge> visitedGraph)Parameters
| Type | Name | Description | 
|---|---|---|
| IVertexListGraph<TVertex, TEdge> | visitedGraph | Graph to visit. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
BreadthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge>, IQueue<TVertex>, IDictionary<TVertex, GraphColor>)
Initializes a new instance of the BreadthFirstSearchAlgorithm<TVertex, TEdge> class.
Declaration
public BreadthFirstSearchAlgorithm(IVertexListGraph<TVertex, TEdge> visitedGraph, IQueue<TVertex> vertexQueue, IDictionary<TVertex, GraphColor> verticesColors)Parameters
| Type | Name | Description | 
|---|---|---|
| IVertexListGraph<TVertex, TEdge> | visitedGraph | Graph to visit. | 
| IQueue<TVertex> | vertexQueue | Queue of vertices to treat. | 
| System.Collections.Generic.IDictionary<TVertex, GraphColor> | verticesColors | Vertices associated to their colors (treatment states). | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
| System.ArgumentNullException | 
 | 
Properties
| Improve this Doc View SourceOutEdgesFilter
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>> | 
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 SourceGetVertexColor(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 | 
 | 
| VertexNotFoundException | 
 | 
Initialize()
Called on algorithm initialization step.
Declaration
protected override void Initialize()Overrides
InternalCompute()
Algorithm compute step.
Declaration
protected override void InternalCompute()Overrides
Events
| Improve this Doc View SourceBlackTarget
Fired when the target vertex of an out-edge from the currently treated vertex is marked as black.
Declaration
public event EdgeAction<TVertex, TEdge> BlackTargetEvent Type
| Type | Description | 
|---|---|
| EdgeAction<TVertex, TEdge> | 
DiscoverVertex
Fired when a vertex is discovered and under treatment.
Declaration
public event VertexAction<TVertex> DiscoverVertexEvent Type
| Type | Description | 
|---|---|
| VertexAction<TVertex> | 
ExamineEdge
Fired when an edge is going to be analyzed.
Declaration
public event EdgeAction<TVertex, TEdge> ExamineEdgeEvent Type
| Type | Description | 
|---|---|
| EdgeAction<TVertex, TEdge> | 
ExamineVertex
Fired when a vertex is going to be analyzed.
Declaration
public event VertexAction<TVertex> ExamineVertexEvent Type
| Type | Description | 
|---|---|
| VertexAction<TVertex> | 
FinishVertex
Fired when a vertex is fully treated.
Declaration
public event VertexAction<TVertex> FinishVertexEvent Type
| Type | Description | 
|---|---|
| VertexAction<TVertex> | 
GrayTarget
Fired when the target vertex of an out-edge from the currently treated vertex is marked as gray.
Declaration
public event EdgeAction<TVertex, TEdge> GrayTargetEvent Type
| Type | Description | 
|---|---|
| EdgeAction<TVertex, TEdge> | 
InitializeVertex
Fired when a vertex is initialized.
Declaration
public event VertexAction<TVertex> InitializeVertexEvent Type
| Type | Description | 
|---|---|
| VertexAction<TVertex> | 
NonTreeEdge
Fired when an edge is going to be treated when coming from a gray vertex.
Declaration
public event EdgeAction<TVertex, TEdge> NonTreeEdgeEvent Type
| Type | Description | 
|---|---|
| EdgeAction<TVertex, TEdge> | 
StartVertex
Fired on a starting vertex once before the start of the search from it.
Declaration
public event VertexAction<TVertex> StartVertexEvent Type
| Type | Description | 
|---|---|
| VertexAction<TVertex> | 
TreeEdge
Fired when an edge is going to be treated when coming from a white vertex.
Declaration
public event EdgeAction<TVertex, TEdge> TreeEdgeEvent Type
| Type | Description | 
|---|---|
| EdgeAction<TVertex, TEdge> |