Graph

Description

sealed class Tinman.Core.Collections.Graph<TNode ref>

Derived from

Disposable abstract

A directed graph (i.e. a set of nodes that are connected with directional links).

Graph nodes are represented by GraphNode objects and carry an immutable user-defined object (see GraphNode.Value).

Graph links are represented by GraphLink objects and carry a mutable user-defined weight value (see GraphLink.Weight).

Public / Constructors

Graph


public constructor Graph → (1)

equals opt : EqualsDelegate<TNode> = null

The node equality delegate. If null, SystemUtilGeneric.EqualsDefault will be used.

Creates a new instance of Graph.

Public / Methods

Clear


public method Clear → ()

Removes all nodes and links from this graph.

Copy


[OwnerReturn]
public method Copy → ()

returns → Graph<TNode>

The created copy.

Creates a copy of this graph.


public method Link → (2)

source in : TNode

The source node.

target in : TNode

The target node.

returns → GraphLink<TNode>

this

Adds a link to the graph.

The link will have a weight of 1.

Link​Null


public method LinkNull → (2)

source in : TNode

The source node.

target in : TNode

The target node.

returns → GraphLink<TNode>

this

Adds a link to the graph.

The link will have a weight of 1.

Node


public method Node → (1)

value in : TNode

The node value to add.

returns → GraphNode<TNode>

The graph node for value in.

Returns the graph node for the given node value, creating it if necessary.

Node​Null


public method NodeNull → (1)

value in : TNode

The node value to add.

returns → GraphNode<TNode>

The graph node for value in or null if no such node exists.

Returns the graph node for the given node value.

Pop​Connected


public method PopConnected → (3)

node in : TNode

[not-null]
The graph node to start.

links opt : int32 = 0

Determines which links to follow:
< 0 : only incoming links to node in
> 0 : only outgoing links from node in
= 0 : both incoming and outgoing links to resp. from node in

sort opt : CompareDelegate<TNode> = null

Optional sort order to apply.

returns → TNode [ ]

The connected nodes (including node in).

Pops all graph nodes that are directly or indirectly connected to the given node.

Pop​Maximum


public method PopMaximum → (1)

compare in : CompareDelegate<GraphNode<TNode>>

[not-null]
The comparer that established an ordering on graph nodes.

returns → TNode [ ]

The maximum value nodes.

Pops the maximum graph nodes, regarding to the given order.

Pop​Minimum


public method PopMinimum → (1)

compare in : CompareDelegate<GraphNode<TNode>>

[not-null]
The comparer that established an ordering on graph nodes.

returns → TNode [ ]

The minimum value nodes.

Pops the minimum graph nodes, regarding to the given order.

Pop​Nodes


public method PopNodes → (1)

sort opt : CompareDelegate<TNode> = null

Optional sort order to apply.

returns → TNode [ ]

The array of node values.

Removes all nodes from the graph and returns their values as an array.

Pop​Sinks


public method PopSinks → (1)

sort opt : CompareDelegate<TNode> = null

Optional sort order to apply.

returns → TNode [ ]

The array of sink node values.

Removes all sink nodes from the graph and returns their values as an array.

Pop​Sources


public method PopSources → (1)

sort opt : CompareDelegate<TNode> = null

Optional sort order to apply.

returns → TNode [ ]

The array of source node values.

Removes all source nodes from the graph and returns their values as an array.

To​String


public method ToString → (3)

toString in : ToStringDelegate<TNode>

[not-null]
Provides textual labels for each graph node.

reverse opt : bool = false

Output reversed links?

horizontal opt : bool = false

Use horizontal layout?

returns → string

The DOT code.

Generates DOT code for this graph.

Public / Attributes


[Constant]
public attribute Links → (get)

value : IBagConst<GraphLink<TNode>>

[not-null]
The set of graph links.

Returns the graph links.

The enumeration order of the links in the returned bag is not necessarily the same as the order in which they have been added to the graph.

Nodes


[Constant]
public attribute Nodes → (get)

value : IBagConst<GraphNode<TNode>>

[not-null]
The set of graph nodes.

Returns the graph nodes.

The enumeration order of the nodes in the returned bag is not necessarily the same as the order in which they have been added to the graph.

See also

Graph.PopNodes

Sink​Nodes


[Constant]
public attribute SinkNodes → (get)

value : IBagConst<GraphNode<TNode>>

[not-null]
The set of graph nodes.

Returns the graph sink nodes (i.e. nodes with no outgoing links).

The enumeration order of the nodes in the returned bag is not necessarily the same as the order in which they have been added to the graph.

See also

Graph.PopSinks

Source​Nodes


[Constant]
public attribute SourceNodes → (get)

value : IBagConst<GraphNode<TNode>>

[not-null]
The set of graph nodes.

Returns the graph source nodes (i.e. nodes with no incoming links).

The enumeration order of the nodes in the returned bag is not necessarily the same as the order in which they have been added to the graph.

See also

Graph.PopSources