A directed graph (i.e. a set of nodes that are connected with directional links).
sealed class
|
Graph
|
with
|
<TNode>
|
||
extends
|
Disposable
|
Graph nodes are represented by GraphNode objects and carry an immutable user-defined object (see Value).
Graph links are represented by GraphLink objects and carry a mutable user-defined weight value (see Weight).
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns the graph links.
public
property
|
Links
{
get
}
|
||
type
|
IBagConst<GraphLink<TNode>>
|
||
value
|
|
The set of graph links. |
Returns the graph nodes.
public
property
|
Nodes
{
get
}
|
||
type
|
IBagConst<GraphNode<TNode>>
|
||
value
|
|
The set of graph nodes. |
Returns the graph sink nodes (i.e. nodes with no outgoing links).
public
property
|
SinkNodes
{
get
}
|
||
type
|
IBagConst<GraphNode<TNode>>
|
||
value
|
|
The set of graph nodes. |
Returns the graph source nodes (i.e. nodes with no incoming links).
public
property
|
SourceNodes
{
get
}
|
||
type
|
IBagConst<GraphNode<TNode>>
|
||
value
|
|
The set of graph nodes. |
Creates a new instance of Graph.
public
constructor
|
Graph
(EqualsDelegate<TNode> equals = null)
|
||
params
|
equals
|
The node equality delegate. |
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Removes all nodes and links from this graph.
public
method
|
Clear
()
|
Creates a copy of this graph.
[OwnerReturn]
|
||||
public
method
|
Copy
()
|
|||
type
|
Graph<TNode>
|
|||
returns
|
|
The created copy. |
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Adds a link to the graph.
public
method
|
Link
(TNode source,
TNode target)
|
||
type
|
GraphLink<TNode>
|
||
params
|
source
|
The source node. | |
target
|
The target node. |
Remarks:
The
link
will
have
a
weight
of
1
.
Adds a link to the graph.
public
method
|
LinkNull
(TNode source,
TNode target)
|
||
type
|
GraphLink<TNode>
|
||
params
|
source
|
The source node. | |
target
|
The target node. |
Remarks:
The
link
will
have
a
weight
of
1
.
Returns the graph node for the given node value, creating it if necessary.
public
method
|
Node
(TNode value)
|
||
type
|
GraphNode<TNode>
|
||
params
|
value
|
The node value to add. | |
returns
|
|
The graph node for value. |
Returns the graph node for the given node value.
public
method
|
NodeNull
(TNode value)
|
||
type
|
GraphNode<TNode>
|
||
params
|
value
|
The node value to add. | |
returns
|
The
graph
node
for
value
or
null
if
no
such
node
exists.
|
Pops all graph nodes that are directly or indirectly connected to the given node.
public
method
|
PopConnected
(TNode node,
CompareDelegate<TNode> sort = null)
|
||
type
|
TNode[]
|
||
params
|
node
|
[not-null]
|
The graph node to start. |
sort
|
Optional sort order to apply. | ||
returns
|
|
The connected nodes (including node). |
Pops the maximum graph nodes, regarding to the given order.
public
method
|
PopMaximium
(CompareDelegate<GraphNode<TNode>> compare)
|
||
type
|
TNode[]
|
||
params
|
compare
|
[not-null]
|
The comparer that established an ordering on graph nodes. |
returns
|
|
The maximum value nodes. |
Pops the minimum graph nodes, regarding to the given order.
public
method
|
PopMinimum
(CompareDelegate<GraphNode<TNode>> compare)
|
||
type
|
TNode[]
|
||
params
|
compare
|
[not-null]
|
The comparer that established an ordering on graph nodes. |
returns
|
|
The minimum value nodes. |
Removes all nodes from the graph and returns their values as an array.
public
method
|
PopNodes
(CompareDelegate<TNode> sort = null)
|
||
type
|
TNode[]
|
||
params
|
sort
|
Optional sort order to apply. | |
returns
|
|
The array of node values. |
Removes all sink nodes from the graph and returns their values as an array.
public
method
|
PopSinks
(CompareDelegate<TNode> sort = null)
|
||
type
|
TNode[]
|
||
params
|
sort
|
Optional sort order to apply. | |
returns
|
|
The array of sink node values. |
Removes all source nodes from the graph and returns their values as an array.
public
method
|
PopSources
(CompareDelegate<TNode> sort = null)
|
||
type
|
TNode[]
|
||
params
|
sort
|
Optional sort order to apply. | |
returns
|
|
The array of source node values. |