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

Inheritance diagram for Graph

Public Member Functions

 __construct (array $attrs=[])
 
 createNestedGraph (Node $parentNode)
 
 getNodeById (string $id)
 
 getEdgeById (string $id)
 
 getAllNodes ()
 Get all nodes in the graph, including nodes in nested graphs. More...
 
 getAllEdges ()
 Get all edges in the graph, including edges in nested graphs. More...
 
 getNodesByAttr (string $key, $value=true)
 Get nodes which have attribute $key equal to $value. More...
 
 getEdgesByAttr (string $key, $value=true)
 Get edges which have attribute $key equal to $value. More...
 
 indexNodeAttr ($key)
 
 indexEdgeAttr ($key)
 
 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

 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 ( array  $attrs = [])

Member Function Documentation

◆ createNestedGraph()

createNestedGraph ( Node  $parentNode)

◆ getNodeById()

getNodeById ( string  $id)

◆ getEdgeById()

getEdgeById ( string  $id)

◆ getAllNodes()

getAllNodes ( )

Get all nodes in the graph, including nodes in nested graphs.

Returns
Node[]
See also
Node[] $nodes

◆ getAllEdges()

getAllEdges ( )

Get all edges in the graph, including edges in nested graphs.

Returns
Edge[]
See also
Edge[] $edges

◆ getNodesByAttr()

getNodesByAttr ( string  $key,
  $value = true 
)

Get nodes which have attribute $key equal to $value.

Parameters
string$key
mixed$value
Returns
Node[]

◆ getEdgesByAttr()

getEdgesByAttr ( string  $key,
  $value = true 
)

Get edges which have attribute $key equal to $value.

Parameters
string$key
mixed$value
Returns
Node[]

◆ indexNodeAttr()

indexNodeAttr (   $key)

◆ indexEdgeAttr()

indexEdgeAttr (   $key)

◆ getRootGraph()

getRootGraph ( )
inherited

◆ getNodes()

getNodes ( )
inherited

Get all nodes in the graph.

Returns
Node[]

◆ getEdges()

getEdges ( )
inherited

Get all edges in the graph.

Returns
Edge[]

◆ createNode()

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

Create node and add it to the graph.

Parameters
string$id
array$attrs
Returns
Node

◆ addNode()

addNode ( Node  $node)
inherited

Add existing node to the graph.

Parameters
Node$node
Returns
NestedGraph

◆ getNode()

getNode ( string  $id)
inherited

Get node by its ID.

Parameters
string$id
Returns
Node

◆ hasNode()

hasNode ( string  $id)
inherited

Returns true if a given node exists within the graph.

◆ removeNode()

removeNode ( Node  $node)
inherited

Remove node and connected edges from the graph.

Parameters
Node$node
Returns
NestedGraph

◆ createEdge()

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

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)
inherited

Add existing edge to the graph.

Parameters
Edge$edge
Returns
NestedGraph

◆ getEdge()

getEdge ( string  $id)
inherited

Get Edge by its ID.

Parameters
string$id
Returns
Edge

◆ hasEdge()

hasEdge ( string  $id)
inherited

Returns true if a given edge exists within the graph.

◆ removeEdge()

removeEdge ( Edge  $edge)
inherited

Remove edge from the graph and disconnect it from nodes.

Parameters
Edge$edge
Returns
NestedGraph

◆ getParentNode()

getParentNode ( )
inherited

◆ nodeAttrChanged()

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

◆ edgeAttrChanged()

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

◆ onAttrChanged()

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

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
protectedinherited

Root graph.

◆ $nodeAttrIndex

ElementAttrIndex $nodeAttrIndex
protectedinherited

Node index.

◆ $edgeAttrIndex

ElementAttrIndex $edgeAttrIndex
protectedinherited

Edge index.