A graph node manages a doubly linked list of GraphArc objects

GraphNode objects are created and managed by the Graph class.

Constructor

new (val:T)

Creates a graph node storing val.

Variables

arcList:GraphArc<T>

The head of a a doubly linked list of GraphArc objects.

depth:Int

The traversal depth (distance from the first traversed node).

@:value(HashKey.next())read onlykey:Int = HashKey.next()

A unique identifier for this object.

A hash table transforms this key into an index of an array element by using a hash function.

marked:Bool

True if the graph node was marked in a DFS/BFS traversal.

next:GraphNode<T>

A reference to the next graph node in the list.

The Graph class manages a doubly linked list of GraphNode objects.

@:value(0)read onlynumArcs:Int = 0

The total number of outgoing arcs.

parent:GraphNode<T>

The node's parent.

During a BFS/DFS traversal, parent points to the previously visited node or to itself if the search originated at that node.

prev:GraphNode<T>

A reference to the previous graph node in the list.

The Graph class manages a doubly linked list of GraphNode objects.

val:T

The node's data.

Methods

@:value({ userData : 1 })addArc (target:GraphNode<T>, userData:Dynamic = 1):GraphNode<T>

Adds an arc pointing from this node to the specified target node.

Parameters:

userData

custom data stored in the arc (optional). For example userData could store a number defining how "hard" it is to get from one node to another.

free ():Void

Destroys this object by explicitly nullifying the element and all pointers for GC'ing used resources.

Improves GC efficiency/performance (optional).

getArc (target:GraphNode<T>):GraphArc<T>

Finds the arc that is pointing to the target node or returns null if such an arc does not exist.

inlineisConnected (target:GraphNode<T>):Bool

Returns true if this node is connected to the target node.

inlineisMutuallyConnected (target:GraphNode<T>):Bool

Returns true if this node and the target node are pointing to each other.

iterator ():Itr<T>

Returns a new NodeValIterator object to iterate over the elements stored in all nodes that are connected to this node by an outgoing arc.

See:

@:value({ mutual : false })removeArc (target:GraphNode<T>, mutual:Bool = false):Bool

Removes the arc that is pointing to the specified target node.

Returns:

true if the arc is successfully removed, false if such an arc does not exist.

removeMutualArcs ():GraphNode<T>

Remove all outgoing and incoming arcs from this node.

removeSingleArcs ():GraphNode<T>

Removes all outgoing arcs from this node.

toString ():String