libSmalldb  v0.7
Public Member Functions | Protected Attributes | List of all members
Graph Class Reference

Public Member Functions

 __construct (&$nodes, &$arrows, $node_tags=[], $arrow_tags=[])
 Constructor. More...
 
 recalculateGraph ()
 Update effective representations of the graph. More...
 
getNode ($node_id)
 
getArrow ($arrow_id)
 
 getNodesByType ($type)
 Get nodes by type. More...
 
 getArrowsByNode ($node)
 Get arrows starting from $node. More...
 
 getArrowsByTargetNode ($node)
 Get arrows ending in $node. More...
 
 tagNode ($node, $tag, $tagged=true)
 Set tag on the node. More...
 
 tagArrow ($arrow, $tag, $tagged=true)
 Set tag on the arrow. More...
 
 getNodesByTag ($tag)
 Get tagged nodes. More...
 
 getArrowsByTag ($tag)
 Get tagged arrows. More...
 

Protected Attributes

 $nodes
 Nodes - source data. More...
 
 $arrows
 Arrows - source data. More...
 
 $arrows_by_node
 Arrows (refs) starting at given node - calculated. More...
 
 $nodes_by_type
 Nodes by type - calculated. More...
 
 $node_tags = []
 Indexed tags for nodes. More...
 
 $arrow_tags = []
 Indexed tags for arrows. More...
 

Constructor & Destructor Documentation

__construct ( $nodes,
$arrows,
  $node_tags = [],
  $arrow_tags = [] 
)

Constructor.

Parameters
&$nodesList of nodes indexed by id. Each node is a key-value array: id, type.
&$arrowsList of arrows indexed by id. Each arrow is a key-value array: id, source, target.
$node_tagsList of tags (keys) which should be indexed on $nodes.
$arrow_tagsList of tags (keys) which should be indexed on $arrows.

Member Function Documentation

recalculateGraph ( )

Update effective representations of the graph.

Call this when graph topology is changed.

getNodesByType (   $type)

Get nodes by type.

Returns
List of references to $nodes.
getArrowsByNode (   $node)

Get arrows starting from $node.

Returns
List of references to $arrows.
getArrowsByTargetNode (   $node)

Get arrows ending in $node.

Returns
List of references to $arrows.
tagNode (   $node,
  $tag,
  $tagged = true 
)

Set tag on the node.

tagArrow (   $arrow,
  $tag,
  $tagged = true 
)

Set tag on the arrow.

getNodesByTag (   $tag)

Get tagged nodes.

getArrowsByTag (   $tag)

Get tagged arrows.

Member Data Documentation

$nodes
protected

Nodes - source data.

$arrows
protected

Arrows - source data.

$arrows_by_node
protected

Arrows (refs) starting at given node - calculated.

$nodes_by_type
protected

Nodes by type - calculated.

$node_tags = []
protected

Indexed tags for nodes.

$arrow_tags = []
protected

Indexed tags for arrows.