Class AlgorithmBase<TGraph>
Base class for all graph algorithm.
Inheritance
Inherited Members
Namespace: QuikGraph.Algorithms
Assembly: QuikGraph.dll
Syntax
[Serializable]
public abstract class AlgorithmBase<TGraph> : IAlgorithm<TGraph>, IComputation, IAlgorithmComponent
Type Parameters
Name | Description |
---|---|
TGraph | Graph type. |
Constructors
| Improve this Doc View SourceAlgorithmBase(TGraph)
Initializes a new instance of the AlgorithmBase<TGraph> class.
Declaration
protected AlgorithmBase(TGraph visitedGraph)
Parameters
Type | Name | Description |
---|---|---|
TGraph | visitedGraph | Graph to visit. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
AlgorithmBase(IAlgorithmComponent, TGraph)
Initializes a new instance of the AlgorithmBase<TGraph> class (with optional host).
Declaration
protected AlgorithmBase(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 |
|
Properties
| Improve this Doc View SourceServices
Algorithm common services.
Declaration
public IAlgorithmServices Services { get; }
Property Value
Type | Description |
---|---|
IAlgorithmServices |
State
Current computation state.
Declaration
public ComputationState State { get; }
Property Value
Type | Description |
---|---|
ComputationState |
SyncRoot
Synchronizer object.
Declaration
public object SyncRoot { get; }
Property Value
Type | Description |
---|---|
System.Object |
VisitedGraph
Gets the graph to visit with this algorithm.
Declaration
public TGraph VisitedGraph { get; }
Property Value
Type | Description |
---|---|
TGraph |
Methods
| Improve this Doc View SourceAbort()
Abort the computation.
Declaration
public void Abort()
Clean()
Called on algorithm cleanup step.
Declaration
protected virtual void Clean()
Compute()
Runs the computation.
Declaration
public void Compute()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Something went wrong when running the algorithm. |
GetService<T>()
Gets the service with given T
.
Declaration
public T GetService<T>()
Returns
Type | Description |
---|---|
T | Found service, otherwise null. |
Type Parameters
Name | Description |
---|---|
T | Service type. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Requested service is not present on algorithm. |
Initialize()
Called on algorithm initialization step.
Declaration
protected virtual void Initialize()
InternalCompute()
Algorithm compute step.
Declaration
protected abstract void InternalCompute()
OnAborted(EventArgs)
Called on algorithm abort.
Declaration
protected virtual void OnAborted(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | EventArgs.Empty. |
OnFinished(EventArgs)
Called on algorithm finished.
Declaration
protected virtual void OnFinished(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | EventArgs.Empty. |
OnStarted(EventArgs)
Called on algorithm start.
Declaration
protected virtual void OnStarted(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | EventArgs.Empty. |
OnStateChanged(EventArgs)
Called on algorithm state changed.
Declaration
protected virtual void OnStateChanged(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | EventArgs.Empty. |
ThrowIfCancellationRequested()
Throws if a cancellation of the algorithm was requested.
Declaration
protected void ThrowIfCancellationRequested()
Exceptions
Type | Condition |
---|---|
System.OperationCanceledException | If the algorithm cancellation service indicates IsCancelling is true. |
TryGetService(Type, out Object)
Tries to get the service with given serviceType
.
Declaration
protected virtual bool TryGetService(Type serviceType, out object service)
Parameters
Type | Name | Description |
---|---|---|
System.Type | serviceType | Service type. |
System.Object | service | Found service. |
Returns
Type | Description |
---|---|
System.Boolean | True if the service was found, false otherwise. |
TryGetService<T>(out T)
Tries to get the service with given T
.
Declaration
public bool TryGetService<T>(out T service)
Parameters
Type | Name | Description |
---|---|---|
T | service | Found service. |
Returns
Type | Description |
---|---|
System.Boolean | True if the service was found, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Service type. |
Events
| Improve this Doc View SourceAborted
Fired when the computation is aborted.
Declaration
public event EventHandler Aborted
Event Type
Type | Description |
---|---|
System.EventHandler |
Finished
Fired when the computation is finished.
Declaration
public event EventHandler Finished
Event Type
Type | Description |
---|---|
System.EventHandler |
Started
Fired when the computation start.
Declaration
public event EventHandler Started
Event Type
Type | Description |
---|---|
System.EventHandler |
StateChanged
Fired when the computation state changed.
Declaration
public event EventHandler StateChanged
Event Type
Type | Description |
---|---|
System.EventHandler |