Graph
in package
implements
JsonSerializable
Represents an ArangoDB Graph.
Tags
Table of Contents
Interfaces
- JsonSerializable
Methods
- __construct() : mixed
- Graph constructor.
- __toString() : string
- Returns a string representation of graph object.
- addEdge() : bool
- Creates a new edge in the collection.<br> Within the attributes the edge has to contain a _from and _to value referencing to valid vertices in the graph Furthermore, the edge has to be valid in the definition of the used.
- addEdgeDefinition() : bool
- Adds an edge definition to graph.
- addVertex() : bool
- Adds a vertex to graph.
- addVertexCollection() : bool
- Adds a vertex collection to the set of orphan collections of the graph.
- delete() : bool
- Removes a graph from server, if possible.
- dropEdge() : bool
- Drops an edge from graph.
- dropEdgeDefinition() : bool
- Remove one edge definition from the graph<br> This will only remove the edge collection, the vertex collections remain untouched and can still be used in your queries.
- dropVertex() : bool
- Drops a vertex from graph.
- dropVertexCollection() : bool
- Removes a vertex collection from the graph and optionally deletes the collection, if it is not used in any other graph<br> It can only remove vertex collections that are no longer part of edge definitions,<br> if they are used in edge definitions you are required to modify those first.
- getEdge() : Edge|false
- Returns an edge document.
- getEdgeDefinitions() : ArrayList
- Return all edge definitions of graph.
- getId() : string
- Returns the graph ID.
- getKey() : string
- Returns the graph key.
- getMinReplicationFactor() : int
- Returns the minimal replication factor used for every new collection in the graph.
- getName() : string
- Gets the graph name.
- getNumberOfShards() : int
- Returns the number of shards that is used for every collection within this graph.
- getOrphanCollections() : array<string|int, mixed>
- Returns the orphan collections in the graph.
- getReplicationFactor() : int
- Returns the replication factor used when initially creating collections for this graph.
- getRevision() : string
- Gets the graph revision.
- getVertex() : Vertex|false
- Gets a vertex from the given collection.
- getVertexCollections() : ArrayList
- Lists all vertex collections within this graph.
- isNew() : bool
- Returns true if is a new graph.
- isSmart() : bool
- If this graph is a smartGraph.
- jsonSerialize() : array<string|int, mixed>|mixed
- Return a JSON representation of graph attributes.
- save() : bool
- Save the Graph on server, if possible.
- toArray() : array<string|int, mixed>
- Returns a array representation of graph.
- traversal() : Traversal
- Returns a graph traversal.
Methods
__construct()
Graph constructor.
public
__construct(string $name[, array<string|int, mixed> $attributes = [] ][, Database|null $database = null ]) : mixed
Parameters
- $name : string
-
Graph name.
- $attributes : array<string|int, mixed> = []
-
Graph optional attributes.
- $database : Database|null = null
-
Database object.
Tags
__toString()
Returns a string representation of graph object.
public
__toString() : string
Return values
stringaddEdge()
Creates a new edge in the collection.<br> Within the attributes the edge has to contain a _from and _to value referencing to valid vertices in the graph Furthermore, the edge has to be valid in the definition of the used.
public
addEdge(string $collection[, array<string|int, mixed> $attributes = [] ][, bool $waitForSync = true ][, bool $returnNew = false ]) : bool
Parameters
- $collection : string
-
The name of the edge collection the edge belongs to.
- $attributes : array<string|int, mixed> = []
-
The object attributes to be stored. Must contain '_to' and '_from' keys.
- $waitForSync : bool = true
-
Define if the request should wait until synced to disk. Default is true.
- $returnNew : bool = false
-
Define if the response should contain the complete new version of the document. Default is false.
Tags
Return values
bool —True if Edge object exists. False if no graph with this name could be found
or this collection is not part of the graph or one of the vertices ('_to' or '_from') does not exist.
addEdgeDefinition()
Adds an edge definition to graph.
public
addEdgeDefinition(string $collection, array<string|int, mixed> $from, array<string|int, mixed> $to) : bool
Parameters
- $collection : string
-
Edge collection name.
- $from : array<string|int, mixed>
-
List of vertex collection names.
- $to : array<string|int, mixed>
-
List of vertex collection names.
Tags
Return values
booladdVertex()
Adds a vertex to graph.
public
addVertex(string $collection[, array<string|int, mixed> $attributes = [] ][, bool $waitForSync = true ][, bool $returnNew = true ]) : bool
Parameters
- $collection : string
-
The name of the vertex collection the vertex should be inserted into.
- $attributes : array<string|int, mixed> = []
-
The object attributes to be stored.
- $waitForSync : bool = true
-
Define if the request should wait until synced to disk. Default is true.
- $returnNew : bool = true
-
Define if the response should contain the complete new version of the document. Default is true.
Tags
Return values
bool —True if the vertex could be added. False if no graph with this name could be found
or if a graph is found but the collection is not part of the graph.
addVertexCollection()
Adds a vertex collection to the set of orphan collections of the graph.
public
addVertexCollection(string $collection) : bool
If the collection does not exist, it will be created.
Parameters
- $collection : string
-
The name of the vertex collection.
Tags
Return values
booldelete()
Removes a graph from server, if possible.
public
delete([bool $dropCollections = false ]) : bool
Parameters
- $dropCollections : bool = false
-
If set true, drop collections of this graph as well.
Collections will only be dropped if they are not used in other graphs.
Tags
Return values
bool —True if operation was successful, false otherwise.
dropEdge()
Drops an edge from graph.
public
dropEdge(string $collection, string $edge[, bool $waitForSync = true ][, bool $returnOld = false ]) : bool
Parameters
- $collection : string
-
The name of the edge collection the edge belongs to.
- $edge : string
-
The _key attribute of the edge.
- $waitForSync : bool = true
-
Define if the request should wait until synced to disk. Default is true.
- $returnOld : bool = false
-
Define if the response should contain the complete new version of the document. Default is false.
Tags
Return values
bool —True if the edge could be removed. False if no graph with this name could be found
or if a graph is found but the collection is not part of the graph.
dropEdgeDefinition()
Remove one edge definition from the graph<br> This will only remove the edge collection, the vertex collections remain untouched and can still be used in your queries.
public
dropEdgeDefinition(string $collection[, bool $dropCollection = false ][, bool $waitForSync = true ]) : bool
Parameters
- $collection : string
-
Edge collection name.
- $dropCollection : bool = false
-
Drop the collection as well. Collection will only be dropped if it is not used in other graphs.
- $waitForSync : bool = true
-
Define if the request should wait until synced to disk.
Tags
Return values
booldropVertex()
Drops a vertex from graph.
public
dropVertex(string $collection, string $vertex[, bool $waitForSync = true ][, bool $returnOld = false ]) : bool
Parameters
- $collection : string
-
The name of the vertex collection the vertex belongs to.
- $vertex : string
-
The _key attribute of the vertex.
- $waitForSync : bool = true
-
Define if the request should wait until synced to disk. Default is true.
- $returnOld : bool = false
-
Define if the response should contain the complete new version of the document. Default is false.
Tags
Return values
bool —True if the vertex could be removed. False if no graph with this name could be found
or if a graph is found but the collection is not part of the graph.
dropVertexCollection()
Removes a vertex collection from the graph and optionally deletes the collection, if it is not used in any other graph<br> It can only remove vertex collections that are no longer part of edge definitions,<br> if they are used in edge definitions you are required to modify those first.
public
dropVertexCollection(string $collection[, bool $dropCollection = false ]) : bool
Parameters
- $collection : string
-
The name of the vertex collection.
- $dropCollection : bool = false
-
Drop the collection as well. Collection will only be dropped if it is not used in other graphs.
Tags
Return values
boolgetEdge()
Returns an edge document.
public
getEdge(string $collection, string $edge) : Edge|false
Parameters
- $collection : string
-
The name of the edge collection the edge belongs to.
- $edge : string
-
The _key attribute of the edge.
Tags
Return values
Edge|false —A Edge object if edge exists. False if no graph with this name could be found
or this collection is not part of the graph or the edge does not exist.
getEdgeDefinitions()
Return all edge definitions of graph.
public
getEdgeDefinitions() : ArrayList
Return values
ArrayListgetId()
Returns the graph ID.
public
getId() : string
Return values
stringgetKey()
Returns the graph key.
public
getKey() : string
Return values
stringgetMinReplicationFactor()
Returns the minimal replication factor used for every new collection in the graph.
public
getMinReplicationFactor() : int
Return values
intgetName()
Gets the graph name.
public
getName() : string
Return values
stringgetNumberOfShards()
Returns the number of shards that is used for every collection within this graph.
public
getNumberOfShards() : int
Return values
intgetOrphanCollections()
Returns the orphan collections in the graph.
public
getOrphanCollections() : array<string|int, mixed>
Return values
array<string|int, mixed>getReplicationFactor()
Returns the replication factor used when initially creating collections for this graph.
public
getReplicationFactor() : int
Return values
intgetRevision()
Gets the graph revision.
public
getRevision() : string
Return values
stringgetVertex()
Gets a vertex from the given collection.
public
getVertex(string $collection, string $vertex) : Vertex|false
Parameters
- $collection : string
-
The name of the vertex collection the vertex belongs to.
- $vertex : string
-
The _key attribute of the vertex.
Tags
Return values
Vertex|false —A Vertex object if vertex exists. False if no graph with this name could be found
or this collection is not part of the graph or the vertex does not exist.
getVertexCollections()
Lists all vertex collections within this graph.
public
getVertexCollections() : ArrayList
Tags
Return values
ArrayListisNew()
Returns true if is a new graph.
public
isNew() : bool
Return values
boolisSmart()
If this graph is a smartGraph.
public
isSmart() : bool
Return values
booljsonSerialize()
Return a JSON representation of graph attributes.
public
jsonSerialize() : array<string|int, mixed>|mixed
Return values
array<string|int, mixed>|mixedsave()
Save the Graph on server, if possible.
public
save() : bool
Tags
Return values
bool —True if operation was successful, false otherwise.
toArray()
Returns a array representation of graph.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>traversal()
Returns a graph traversal.
public
traversal(Vertex $vertex[, string $direction = Traversal::GRAPH_DIRECTION_ANY ][, int $depth = 0 ]) : Traversal
Parameters
- $vertex : Vertex
-
The start vertex.
- $direction : string = Traversal::GRAPH_DIRECTION_ANY
-
Direction for traversal. Must be either "outbound", "inbound", or "any".
- $depth : int = 0
-
Visits only nodes in at least the given depth.