libSmalldb  v2.0.2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NestedGraph Class Reference

Inheritance diagram for NestedGraph

Public Member Functions

 getRootGraph ()
 
 getNodes ()
 Get all nodes in the graph. More...
 
 getEdges ()
 Get all edges in the graph. More...
 
 createNode (string $id, array $attrs=[])
 Create node and add it to the graph. More...
 
 addNode (Node $node)
 Add existing node to the graph. More...
 
 getNode (string $id)
 Get node by its ID. More...
 
 hasNode (string $id)
 Returns true if a given node exists within the graph. More...
 
 removeNode (Node $node)
 Remove node and connected edges from the graph. More...
 
 createEdge (?string $id, Node $start, Node $end, array $attrs=[])
 Create a new edge and add it to the graph. More...
 
 addEdge (Edge $edge)
 Add existing edge to the graph. More...
 
 getEdge (string $id)
 Get Edge by its ID. More...
 
 hasEdge (string $id)
 Returns true if a given edge exists within the graph. More...
 
 removeEdge (Edge $edge)
 Remove edge from the graph and disconnect it from nodes. More...
 
 getParentNode ()
 
 nodeAttrChanged ($node, $key, $oldValue, $newValue)
 
 edgeAttrChanged ($node, $key, $oldValue, $newValue)
 
 offsetSet ($key, $value)
 
offsetGet ($key)
 
 getAttr (string $key, $defaultValue=null)
 
 offsetUnset ($key)
 
 setAttr (string $key, $newValue)
 
 removeAttr (string $key)
 
 offsetExists ($key)
 
 getAttributes ()
 

Protected Member Functions

 __construct (Node $parentNode=null, array $attrs=[])
 Constructor. More...
 
 onAttrChanged (string $key, $oldValue, $newValue)
 Handle change of an attribute. More...
 

Protected Attributes

Graph $rootGraph = null
 Root graph. More...
 
ElementAttrIndex $nodeAttrIndex
 Node index. More...
 
ElementAttrIndex $edgeAttrIndex
 Edge index. More...
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Node  $parentNode = null,
array  $attrs = [] 
)
protected

Constructor.

Member Function Documentation

◆ getRootGraph()

getRootGraph ( )

◆ getNodes()

getNodes ( )

Get all nodes in the graph.

Returns
Node[]

◆ getEdges()

getEdges ( )

Get all edges in the graph.

Returns
Edge[]

◆ createNode()

createNode ( string  $id,
array  $attrs = [] 
)

Create node and add it to the graph.

Parameters
string$id
array$attrs
Returns
Node

◆ addNode()

addNode ( Node  $node)

Add existing node to the graph.

Parameters
Node$node
Returns
NestedGraph

◆ getNode()

getNode ( string  $id)

Get node by its ID.

Parameters
string$id
Returns
Node

◆ hasNode()

hasNode ( string  $id)

Returns true if a given node exists within the graph.

◆ removeNode()

removeNode ( Node  $node)

Remove node and connected edges from the graph.

Parameters
Node$node
Returns
NestedGraph

◆ createEdge()

createEdge ( ?string  $id,
Node  $start,
Node  $end,
array  $attrs = [] 
)

Create a new edge and add it to the graph.

Parameters
string | null$idID of the edge, generated automatically if null.
array$attrsKey-value storage of the edge attributes.
Node$start
Node$end
Returns
Edge

◆ addEdge()

addEdge ( Edge  $edge)

Add existing edge to the graph.

Parameters
Edge$edge
Returns
NestedGraph

◆ getEdge()

getEdge ( string  $id)

Get Edge by its ID.

Parameters
string$id
Returns
Edge

◆ hasEdge()

hasEdge ( string  $id)

Returns true if a given edge exists within the graph.

◆ removeEdge()

removeEdge ( Edge  $edge)

Remove edge from the graph and disconnect it from nodes.

Parameters
Edge$edge
Returns
NestedGraph

◆ getParentNode()

getParentNode ( )

◆ nodeAttrChanged()

nodeAttrChanged (   $node,
  $key,
  $oldValue,
  $newValue 
)

◆ edgeAttrChanged()

edgeAttrChanged (   $node,
  $key,
  $oldValue,
  $newValue 
)

◆ onAttrChanged()

onAttrChanged ( string  $key,
  $oldValue,
  $newValue 
)
protected

Handle change of an attribute.

◆ offsetSet()

offsetSet (   $key,
  $value 
)
inherited

◆ offsetGet()

& offsetGet (   $key)
inherited

◆ getAttr()

getAttr ( string  $key,
  $defaultValue = null 
)
inherited

◆ offsetUnset()

offsetUnset (   $key)
inherited

◆ setAttr()

setAttr ( string  $key,
  $newValue 
)
inherited
Returns
$this

◆ removeAttr()

removeAttr ( string  $key)
inherited
Returns
$this

◆ offsetExists()

offsetExists (   $key)
inherited

◆ getAttributes()

getAttributes ( )
inherited

Member Data Documentation

◆ $rootGraph

Graph $rootGraph = null
protected

Root graph.

◆ $nodeAttrIndex

ElementAttrIndex $nodeAttrIndex
protected

Node index.

◆ $edgeAttrIndex

ElementAttrIndex $edgeAttrIndex
protected

Edge index.