Packagecom.asterisq.graph
Classpublic class LinkedGraph
InheritanceLinkedGraph Inheritance flash.events.EventDispatcher
ImplementsIGraph

Stores graph data and maintains references between nodes and edges.



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

Creates a new linked graph.

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.

Throws
GraphError — Throws GraphError.DUPLICATE_EDGE if the graph already contains an edge with the given ID.
 
GraphError — Throws GraphError.MISSING_TAIL_NODE if the graph does not contain a node with the given tail node ID.
 
GraphError — Throws GraphError.MISSING_HEAD_NODE if the graph does not contain a node with the given head node ID.
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.

Throws
GraphError — Throws GraphError.DUPLICATE_NODE if the graph already contains a node with the given ID.
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.
getConnectedGraphs()method 
public function getConnectedGraphs():Array

Fetches an array of connected graphs that are contained in this graph. If the graph is connected, one graph identical to this graph is returned.

Returns
Array
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
getNodesWithSameNeighbors()method 
public function getNodesWithSameNeighbors(node:LinkedNode):Array

Fetches the nodes that have the same neighbors as the given node.

Parameters
node:LinkedNode

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.


Throws
GraphError — Throws GraphError.REFERENCED_NODE if there are any edges.
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

Throws
GraphError — Throws GraphError.REFERENCED_NODE if the given node is referenced by any edges.
removeNodeAndEdges()method 
public function removeNodeAndEdges(node:LinkedNode):void

Removes a node and all its edges.

Parameters
node:LinkedNode
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.
toGraph()method 
public function toGraph():Graph

Converts this LinkedGraph to a Graph

Returns
Graph

See also

toString()method 
public override function toString():String

Returns
String