Class: ModelGraph

ModelGraph

A ModelGraph models a set of LogEvents as a graph. The graph is generated based on the LogEvents passed to the constructor. One ModelNode is created for each LogEvent The "ordering" of ModelNodes and the hosts to which they belong is based on the natural ordering of the LogEvents.

Constructor

new ModelGraph(logEvents)

Constructs a ModelGraph from an array of LogEvents
Parameters:
Name Type Description
logEvents Array.<LogEvent> The array of LogEvents from which to generate the model.
Source:

Extends

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
Inherited From:
Source:

clone() → {ModelGraph}

Returns a copy of the graph. The new graph has nodes connected in exactly the same way as the original. The new graph has exactly the same set of hosts. The node themselves are shallow copies provided by node.clone()
Source:
Returns:
The copy of the graph
Type
ModelGraph

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.

Inherited From:
Source:
Returns:
an array of all nodes in the model
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.

Inherited From:
Source:
Returns:
an array of all dummy nodes
Type
Array.<AbstractNode>

getHead(host) → {AbstractNode}

Gets the dummy head node for a host.
Parameters:
Name Type Description
host String the name of the host
Inherited From:
Source:
Returns:
the head node, or null if none is found
Type
AbstractNode

getHosts() → {Array.<String>}

Gets the hosts as an array
Inherited From:
Source:
Returns:
a copy of the array of host names
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.

Inherited From:
Source:
Returns:
an array of all non-dummy nodes
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.

Inherited From:
Source:
Throws:
An exception if the graph contains a cycle. There cannot exist a topologically sorted order if there exists a cycle.
Returns:
the nodes in topologically sorted order.
Type
Array.<AbstractNode>

getTail(host) → {AbstractNode}

Gets the dummy tail node for a host
Parameters:
Name Type Description
host String the name of the host
Inherited From:
Source:
Returns:
the tail node, or null if none is found
Type
AbstractNode

hasHost(host) → {Boolean}

Checks if this graph has the specified host
Parameters:
Name Type Description
host String The host to check for
Inherited From:
Source:
Returns:
True if the host exists
Type
Boolean

removeHost(host)

Removes a host from the model. The host itself and all nodes on the host will be removed. In addition all connections to and from this host will be removed. If the host doesn't exist, this method does nothing
Parameters:
Name Type Description
host String the name of the host to hide
Inherited From:
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.
Inherited From:
Source: