Packagecom.asterisq.graph
Interfacepublic interface IGraph extends flash.events.IEventDispatcher
SubinterfacesIEdge, INode
ImplementorsGraph, LinkedGraph

Interface for a graph.



Public Properties
 PropertyDefined by
  edgeLength : uint
[read-only] The number of edges in this graph.
IGraph
  edges : Array
[read-only] A list of the edges in this graph.
IGraph
  nodeLength : uint
[read-only] The number of nodes in this graph.
IGraph
  nodes : Array
[read-only] A list of the nodes in this graph.
IGraph
Public Methods
 MethodDefined by
  
addEdge(id:String, tailNodeID:String, headNodeID:String, data:Object = null):IEdge
Adds a new edge to this graph.
IGraph
  
addGraph(graph:IGraph):Boolean
Adds the nodes and edges in the given graph to this graph.
IGraph
  
addNode(id:String, data:Object = null):INode
Adds a new node to this graph.
IGraph
  
clear():void
Clears all nodes and edges in this graph.
IGraph
  
filterByEdge(func:Function, result:IGraph = null):IGraph
Builds a graph containing only the edge which pass the given test function.
IGraph
  
filterByNode(func:Function, result:IGraph = null):IGraph
Builds a graph containing only the nodes which pass the given test function and their edges.
IGraph
  
getEdgeByDataProperty(propertyName:String, value:*):IEdge
Fetches the first edge matching the given data property name and value.
IGraph
  
getEdgeByHeadNodeID(nodeID:String):IEdge
Fetches an edge given the ID of its head node.
IGraph
  
getEdgeByID(id:String):IEdge
Fetches an edge given its ID.
IGraph
  
getEdgeByNodeID(nodeID:String):IEdge
Fetches an edge given the ID of one of its nodes.
IGraph
  
getEdgeByNodeIDs(tailNodeID:String, headNodeID:String, bidirectional:Boolean = false):IEdge
Fetches an edge given the IDs of its nodes.
IGraph
  
getEdgeByTailNodeID(nodeID:String):IEdge
Fetches an edge given the ID of its tail node.
IGraph
  
getEdgesByDataProperty(propertyName:String, value:*):Array
Fetches a list of all edges matching the given data property name and value.
IGraph
  
getNodeByDataProperty(propertyName:String, value:*):INode
Fetches the first node matching the given data property name and value.
IGraph
  
getNodeByID(id:String):INode
Fetches a node given its ID.
IGraph
  
getNodesByDataProperty(propertyName:String, value:*):Array
Fetches all nodes matching the given data property name and value.
IGraph
  
hasEdge(id:String):Boolean
Determines whether the graph contains an edge with the given ID.
IGraph
  
hasNode(id:String):Boolean
Determines whether a node with the given ID exists in this graph.
IGraph
  
Removes all edges from this node graph.
IGraph
  
Removes all nodes from this graph.
IGraph
  
removeEdge(edge:IEdge):void
Removes the given edge from the node graph.
IGraph
  
removeNode(node:INode):void
Removes the given node from this node graph.
IGraph
  
setGraph(graph:IGraph):Boolean
Updates the contents of this graph to the given graph.
IGraph
Property detail
edgeLengthproperty
edgeLength:uint  [read-only]

The number of edges in this graph.

Implementation
    public function get edgeLength():uint
edgesproperty 
edges:Array  [read-only]

A list of the edges in this graph.

Implementation
    public function get edges():Array
nodeLengthproperty 
nodeLength:uint  [read-only]

The number of nodes in this graph.

Implementation
    public function get nodeLength():uint
nodesproperty 
nodes:Array  [read-only]

A list of the nodes in this graph.

Implementation
    public function get nodes():Array
Method detail
addEdge()method
public function addEdge(id:String, tailNodeID:String, headNodeID:String, data:Object = null):IEdge

Adds a new edge to this graph.

Parameters
id:String — A permanent, unique ID for the new edge.
 
tailNodeID:String — The ID of the tail node of the new edge.
 
headNodeID:String — The ID of the head node of the new edge.
 
data:Object (default = null) — Data to be associated with the new edge.

Returns
IEdge — The new edge.
addGraph()method 
public function addGraph(graph:IGraph):Boolean

Adds the nodes and edges in the given graph to this graph. Nodes with duplicate IDs are ignored.

NOTE: Node and edge properties are not copied across.

Parameters
graph:IGraph

Returns
Boolean — True if the graph changed false if the graphs were equivalent.
addNode()method 
public function addNode(id:String, data:Object = null):INode

Adds a new node to this graph.

Parameters
id:String — A permanent, unique ID for the new node.
 
data:Object (default = null) — Data to be associated with the new node.

Returns
INode — The new node.
clear()method 
public function clear():void

Clears all nodes and edges in this graph.

filterByEdge()method 
public function filterByEdge(func:Function, result:IGraph = null):IGraph

Builds a graph containing only the edge which pass the given test function.

Parameters
func:Function — The edge test function which takes an IEdge as a parameter and returns true if the edge should be included in the resulting graph.
 
result:IGraph (default = null) — Stores the resulting graph. If null, a new Graph is returned.

Returns
IGraph — A new graph containing edges that passed the filter function.
filterByNode()method 
public function filterByNode(func:Function, result:IGraph = null):IGraph

Builds a graph containing only the nodes which pass the given test function and their edges.

Parameters
func:Function — The node test function which takes an INode as a parameter and returns true if the node should be included in the resulting graph.
 
result:IGraph (default = null) — Stores the resulting graph. If null, a new Graph is returned.

Returns
IGraph — A new graph containing nodes that passed the filter function and their edges.
getEdgeByDataProperty()method 
public function getEdgeByDataProperty(propertyName:String, value:*):IEdge

Fetches the first edge matching the given data property name and value.

Parameters
propertyName:String
 
value:*

Returns
IEdge
getEdgeByHeadNodeID()method 
public function getEdgeByHeadNodeID(nodeID:String):IEdge

Fetches an edge given the ID of its head node.

Parameters
nodeID:String

Returns
IEdge
getEdgeByID()method 
public function getEdgeByID(id:String):IEdge

Fetches an edge given its ID.

Parameters
id:String

Returns
IEdge
getEdgeByNodeID()method 
public function getEdgeByNodeID(nodeID:String):IEdge

Fetches an edge given the ID of one of its nodes.

Parameters
nodeID:String

Returns
IEdge
getEdgeByNodeIDs()method 
public function getEdgeByNodeIDs(tailNodeID:String, headNodeID:String, bidirectional:Boolean = false):IEdge

Fetches an edge given the IDs of its nodes.

Parameters
tailNodeID:String — The ID of the edge's tail node.
 
headNodeID:String — The ID of the edge's head node.
 
bidirectional:Boolean (default = false) — Indicates whether the tail node ID and head node ID can be swapped.

Returns
IEdge — The edge with the given nodes or null if it doesn't exist.
getEdgeByTailNodeID()method 
public function getEdgeByTailNodeID(nodeID:String):IEdge

Fetches an edge given the ID of its tail node.

Parameters
nodeID:String

Returns
IEdge
getEdgesByDataProperty()method 
public function getEdgesByDataProperty(propertyName:String, value:*):Array

Fetches a list of all edges matching the given data property name and value.

Parameters
propertyName:String
 
value:*

Returns
Array
getNodeByDataProperty()method 
public function getNodeByDataProperty(propertyName:String, value:*):INode

Fetches the first node matching the given data property name and value.

Parameters
propertyName:String
 
value:*

Returns
INode
getNodeByID()method 
public function getNodeByID(id:String):INode

Fetches a node given its ID.

Parameters
id:String

Returns
INode
getNodesByDataProperty()method 
public function getNodesByDataProperty(propertyName:String, value:*):Array

Fetches all nodes matching the given data property name and value.

Parameters
propertyName:String
 
value:*

Returns
Array
hasEdge()method 
public function hasEdge(id:String):Boolean

Determines whether the graph contains an edge with the given ID.

Parameters
id:String

Returns
Boolean
hasNode()method 
public function hasNode(id:String):Boolean

Determines whether a node with the given ID exists in this graph.

Parameters
id:String

Returns
Boolean
removeAllEdges()method 
public function removeAllEdges():void

Removes all edges from this node graph.

removeAllNodes()method 
public function removeAllNodes():void

Removes all nodes from this graph.

removeEdge()method 
public function removeEdge(edge:IEdge):void

Removes the given edge from the node graph.

Parameters
edge:IEdge
removeNode()method 
public function removeNode(node:INode):void

Removes the given node from this node graph.

Parameters
node:INode
setGraph()method 
public function setGraph(graph:IGraph):Boolean

Updates the contents of this graph to the given graph. If a node or edge is not contained in the given graph, it is removed. If a node or edge is present in the given graph but not in this graph, it is added.

NOTE: Properties of common nodes and edges will be overwritten.

Parameters
graph:IGraph

Returns
Boolean — True if the graph was changed, false if the graphs were equivalent.