Class RootedAlgorithmBase<TVertex, TGraph>
Base class for all graph algorithm requiring a starting vertex (root).
Inherited Members
Namespace: QuikGraph.Algorithms
Assembly: QuikGraph.dll
Syntax
[Serializable]
public abstract class RootedAlgorithmBase<TVertex, TGraph> : AlgorithmBase<TGraph>, IAlgorithm<TGraph>, IComputation, IAlgorithmComponent where TGraph : IImplicitVertexSet<TVertex>
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TGraph | Graph type. |
Remarks
Requires a starting vertex (root).
Constructors
| Improve this Doc View SourceRootedAlgorithmBase(IAlgorithmComponent, TGraph)
Initializes a new instance of the RootedAlgorithmBase<TVertex, TGraph> class.
Declaration
protected RootedAlgorithmBase(IAlgorithmComponent host, TGraph visitedGraph)
Parameters
Type | Name | Description |
---|---|---|
IAlgorithmComponent | host | Host to use if set, otherwise use this reference. |
TGraph | visitedGraph | Graph to visit. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Methods
| Improve this Doc View SourceAssertRootInGraph(TVertex)
Asserts that the given root
vertex is in the VisitedGraph.
Declaration
protected void AssertRootInGraph(TVertex root)
Parameters
Type | Name | Description |
---|---|---|
TVertex | root | Vertex to check. |
Exceptions
Type | Condition |
---|---|
VertexNotFoundException | If the set root vertex is not part of the VisitedGraph. |
ClearRootVertex()
Clears the root vertex.
Declaration
public void ClearRootVertex()
Compute(TVertex)
Runs the algorithm with the given root
vertex.
Declaration
public virtual void Compute(TVertex root)
Parameters
Type | Name | Description |
---|---|---|
TVertex | root | Root vertex. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.InvalidOperationException | Something went wrong when running the algorithm. |
GetAndAssertRootInGraph()
Gets the root vertex if set and checks it is part of the VisitedGraph.
Declaration
protected TVertex GetAndAssertRootInGraph()
Returns
Type | Description |
---|---|
TVertex | Root vertex. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | If the root vertex has not been set. |
VertexNotFoundException | If the set root vertex is not part of the VisitedGraph. |
OnRootVertexChanged(EventArgs)
Called on each root vertex change.
Declaration
protected virtual void OnRootVertexChanged(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | EventArgs.Empty. |
SetRootVertex(TVertex)
Sets the root vertex.
Declaration
public void SetRootVertex(TVertex root)
Parameters
Type | Name | Description |
---|---|---|
TVertex | root | Root vertex. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
TryGetRootVertex(out TVertex)
Tries to get the root vertex if set.
Declaration
public bool TryGetRootVertex(out TVertex root)
Parameters
Type | Name | Description |
---|---|---|
TVertex | root | Root vertex if set, otherwise null. |
Returns
Type | Description |
---|---|
System.Boolean | True if the root vertex was set, false otherwise. |
Events
| Improve this Doc View SourceRootVertexChanged
Fired when the root vertex is changed.
Declaration
public event EventHandler RootVertexChanged
Event Type
Type | Description |
---|---|
System.EventHandler |