Hoa central
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Hoa\Graph\Graph Class Reference
Inheritance diagram for Hoa\Graph\Graph:

Public Member Functions

 addNode (IGraph\Node $node, $parent=[])
 
 nodeExists ($nodeId)
 
 getNode ($nodeId)
 
 getParent ($nodeId)
 
 getChild ($nodeId)
 
 deleteNode ($nodeId, $propagate=self::DELETE_RESTRICT)
 
 isLeaf ($nodeId)
 
 isRoot ($nodeId)
 
 allowLoop ($loop=self::DISALLOW_LOOP)
 
 isLoopAllow ()
 
 __toString ()
 

Static Public Member Functions

static getInstance ($type=self::TYPE_ADJACENCYLIST)
 

Public Attributes

const TYPE_ADJACENCYLIST = 'AdjacencyList'
 
const ALLOW_LOOP = true
 
const DISALLOW_LOOP = false
 
const DELETE_CASCADE = true
 
const DELETE_RESTRICT = false
 

Protected Member Functions

 __construct ($loop=self::DISALLOW_LOOP)
 
 getNodes ()
 

Protected Attributes

 $nodes = []
 
 $loop = self::DISALLOW_LOOP
 

Detailed Description

Class .

Get instance of different graph type. When getting an instance of a type of a graph, the graph type (e.g. ) extends this class. It is like an abstract factory…

Definition at line 52 of file Graph.php.

Constructor & Destructor Documentation

Hoa\Graph\Graph::__construct (   $loop = self::DISALLOW_LOOP)
protected

Get an empty graph.

Parameters
bool$loopAllow or not loop.
Returns
void

Definition at line 112 of file Graph.php.

113  {
114  $this->allowLoop($loop);
115 
116  return;
117  }
allowLoop($loop=self::DISALLOW_LOOP)
Definition: Graph.php:232

Here is the call graph for this function:

Member Function Documentation

Hoa\Graph\Graph::__toString ( )
abstract

Print the graph in the DOT language.

Returns
string
Hoa\Graph\Graph::addNode ( IGraph\Node  $node,
  $parent = [] 
)
abstract

Add a node.

Parameters
\Hoa\Graph\IGraph\Node$nodeNode to add.
mixed$parentParent of node.
Returns
void
Exceptions
Hoa\Graph\Graph::allowLoop (   $loop = self::DISALLOW_LOOP)

Set the loop mode (self::ALLOW_LOOP or self::DISALLOW_LOOP).

Parameters
bool$loopAllow or not loop.
Returns
bool

Definition at line 232 of file Graph.php.

233  {
234  $old = $this->loop;
235  $this->loop = $loop;
236 
237  return $old;
238  }

Here is the caller graph for this function:

Hoa\Graph\Graph::deleteNode (   $nodeId,
  $propagate = self::DELETE_RESTRICT 
)
abstract

Delete a node.

Parameters
mixed$nodeIdThe node ID or the node instance.
bool$propagatePropagate the erasure.
Returns
void
Exceptions
Hoa\Graph\Graph::getChild (   $nodeId)
abstract

Get child of a specific node.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
object
Exceptions
static Hoa\Graph\Graph::getInstance (   $type = self::TYPE_ADJACENCYLIST)
static

Make an instance of a specific graph.

Parameters
string$typeType of graph needed.
Returns
Exceptions

Definition at line 126 of file Graph.php.

127  {
128  if ($type != self::TYPE_ADJACENCYLIST) {
129  throw new Exception(
130  'Type %s is not supported. Only self:TYPE_ADJACENCYLIST is ' .
131  'supported.',
132  0,
133  $type
134  );
135  }
136 
137  $arguments = func_get_args();
138  array_shift($arguments);
139 
140  return dnew('Hoa\Graph\\' . $type, $arguments);
141  }

Here is the caller graph for this function:

Hoa\Graph\Graph::getNode (   $nodeId)
abstract

Get a node.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
object
Exceptions
Hoa\Graph\Graph::getNodes ( )
protected

Get all nodes.

Returns
array

Definition at line 175 of file Graph.php.

176  {
177  return $this->nodes;
178  }

Here is the caller graph for this function:

Hoa\Graph\Graph::getParent (   $nodeId)
abstract

Get parent of a specific node.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
object
Exceptions
Hoa\Graph\Graph::isLeaf (   $nodeId)
abstract

Whether node is a leaf, i.e. does not have any child.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
bool
Exceptions
Hoa\Graph\Graph::isLoopAllow ( )

Get the loop mode.

Returns
bool

Definition at line 245 of file Graph.php.

246  {
247  return $this->loop;
248  }

Here is the caller graph for this function:

Hoa\Graph\Graph::isRoot (   $nodeId)
abstract

Whether node is a root, i.e. does not have any parent.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
bool
Exceptions
Hoa\Graph\Graph::nodeExists (   $nodeId)
abstract

Check if a node does already exist or not.

Parameters
mixed$nodeIdThe node ID or the node instance.
Returns
bool

Member Data Documentation

Hoa\Graph\Graph::$loop = self::DISALLOW_LOOP
protected

Definition at line 102 of file Graph.php.

Hoa\Graph\Graph::$nodes = []
protected

Definition at line 94 of file Graph.php.

const Hoa\Graph\Graph::ALLOW_LOOP = true

Allow loop when building graph (when adding nodes).

bool

Definition at line 66 of file Graph.php.

const Hoa\Graph\Graph::DELETE_CASCADE = true

Propagate delete.

bool

Definition at line 80 of file Graph.php.

const Hoa\Graph\Graph::DELETE_RESTRICT = false

Restrict delete.

bool

Definition at line 87 of file Graph.php.

const Hoa\Graph\Graph::DISALLOW_LOOP = false

Disallow loop when building graph (when adding nodes).

bool

Definition at line 73 of file Graph.php.

const Hoa\Graph\Graph::TYPE_ADJACENCYLIST = 'AdjacencyList'

Graph type.

string

Definition at line 59 of file Graph.php.


The documentation for this class was generated from the following file: