\GraphDS\GraphDirectedGraph

Class defining a directed graph object.

Summary

Methods
Properties
Constants
__construct()
getVertexCount()
getEdgeCount()
addVertex()
removeVertex()
edge()
addEdge()
removeEdge()
getTranspose()
$vertices
$edges
$directed
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$vertices

$vertices : array

An array holding all vertices of the graph.

Type

array

$edges

$edges : array

An array holding all edges of the graph.

Type

array

$directed

$directed : boolean

Defines whether the graph is directed or not.

Type

boolean

Methods

__construct()

__construct() 

Constructor for DirectedGraph object.

getVertexCount()

getVertexCount() : integer

Returns the number of vertices in the graph.

Returns

integer —

Number of vertices in the graph

getEdgeCount()

getEdgeCount() : integer

Returns the number of edges in the graph.

Returns

integer —

Number of edges in the graph

addVertex()

addVertex(string  $vertex) 

Adds a directed vertex to the graph.

Parameters

string $vertex

ID of the vertex

removeVertex()

removeVertex(string  $vertex) 

Removes a directed vertex from the graph.

Parameters

string $vertex

ID of the vertex

Throws

\InvalidArgumentException

edge()

edge(string  $vertex1, string  $vertex2) : object

Returns an edge object in the graph from $vertex1 to $vertex2.

Parameters

string $vertex1

ID of first vertex

string $vertex2

ID of second vertex

Throws

\InvalidArgumentException

Returns

object —

Instance of DirectedEdge from $vertex1 to $vertex2

addEdge()

addEdge(string  $vertex1, string  $vertex2, float  $value = null) 

Adds a directed edge between two directed vertices ($vertex1 to $vertex2).

Parameters

string $vertex1

ID of first vertex

string $vertex2

ID of second vertex

float $value

The value/weight the edge should hold

Throws

\InvalidArgumentException

removeEdge()

removeEdge(string  $vertex1, string  $vertex2) 

Removes a directed edge between two directed vertices ($vertex1 to $vertex2).

Parameters

string $vertex1

ID of first vertex

string $vertex2

ID of second vertex

Throws

\InvalidArgumentException

getTranspose()

getTranspose() : \GraphDS\Graph\DirectedGraph

Transposes the graph, reversing each directed edge.

Throws

\InvalidArgumentException

Returns

\GraphDS\Graph\DirectedGraph

The transposed graph