Constructor
(abstract) new AbstractGraph()
- Source:
Methods
addObserver(type, context, callback)
Adds an observer to this graph. The observer will be notified (by invoking the provided callback function) of events when events of the specified type occur. There cannot exist two observers that are identical. The newly added observer will replace another if it is identical to the other one. Two observers are considered identical if they were registered with the same type and callback.
Parameters:
Name | Type | Description |
---|---|---|
type |
function | The type of event you want to observe. Use the constructor function of the event class. For example, if you want to observe AddNodeEvents, type would just be "AddNodeEvent". |
context |
* | This object will be provided to the callback function when it is invoked. |
callback |
AbstractGraph~ObserverCallback | The callback function. The parameters of the callback should be event, context |
- Source:
getAllNodes() → {Array.<AbstractNode>}
Gets all nodes including dummy nodes
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of nodes.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getDummyNodes() → {Array.<AbstractNode>}
Gets all dummy (head/tail) nodes in the graph as an array.
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of nodes.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getHead(host) → {AbstractNode}
Parameters:
Name | Type | Description |
---|---|---|
host |
String | the name of the host |
- Source:
Returns:
- Type
- AbstractNode
getHosts() → {Array.<String>}
- Source:
Returns:
- Type
- Array.<String>
getNodes() → {Array.<AbstractNode>}
Gets all non-dummy (i.e non-head and non-tail) nodes in the graph as an array.
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of nodes.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getNodesTopologicallySorted() → {Array.<AbstractNode>}
Returns the non-dummy nodes of the graph in topologically sorted order. A topologically sorted order is one where, for all i and j such that j > i, there does not exist a directed edge from nodes[j] to nodes[i].
In the case that there are multiple permissible orderings, this method makes no guarantees about which one will be returned. This method may not even return the same order each time it's called.
- Source:
Throws:
Returns:
- Type
- Array.<AbstractNode>
getTail(host) → {AbstractNode}
Parameters:
Name | Type | Description |
---|---|---|
host |
String | the name of the host |
- Source:
Returns:
- Type
- AbstractNode
hasHost(host) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
host |
String | The host to check for |
- Source:
Returns:
- Type
- Boolean
removeHost(host)
Parameters:
Name | Type | Description |
---|---|---|
host |
String | the name of the host to hide |
- Source:
removeObserver(type, callback)
Removes an observer from this graph. If the specified observer cannot be found, this function does nothing.
Parameters:
Name | Type | Description |
---|---|---|
type |
function | The type of event you want to observe. Use the constructor function of the event class. For example, if you want to remove an observer for AbstractGraphs, type would just be "AddNodeEvent". |
callback |
AbstractGraph~ObserverCallback | The callback function. |
- Source:
Type Definitions
ObserverCallback(event, context)
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | The event object. |
context |
* | Arbitrary data provided to the callback function specified when adding observers |
- Source: