Switchboard SDK
Loading...
Searching...
No Matches
switchboard::Graph Class Reference

Represents a general purpose DAG (Directed Acyclic Graph) with nodes and edges. More...

#include <Graph.hpp>

Public Member Functions

 Graph ()
 Creates a Graph instance.
 
 ~Graph ()
 Graph destructor.
 
uint getNumberOfNodes () const
 Returns the number of nodes in the graph.
 
uint addNode ()
 Adds a node the graph.
 
bool removeNode (uint node)
 Removes a node from the graph.
 
bool addEdge (const uint startNode, const uint endNode)
 Adds an edge between two nodes.
 
bool removeEdge (const uint startNode, const uint endNode)
 Removes an edge from between two nodes.
 
const std::vector< uint > & getOutNodes (const uint startNode)
 Returns out nodes for a given node.
 
const std::vector< uint > & getInNodes (const uint endNode)
 Returns in nodes for a given node.
 
bool isCyclic ()
 Checks whether the graph is cyclic.
 

Detailed Description

Represents a general purpose DAG (Directed Acyclic Graph) with nodes and edges.

Graph classes.

Member Function Documentation

◆ addEdge()

bool switchboard::Graph::addEdge ( const uint startNode,
const uint endNode )

Adds an edge between two nodes.

Parameters
startNodeThe start node.
endNodeThe end node.
Returns
True if edge was added successfully, false otherwise.

◆ addNode()

uint switchboard::Graph::addNode ( )

Adds a node the graph.

Returns
The ID of the new node.

◆ getInNodes()

const vector< uint > & switchboard::Graph::getInNodes ( const uint endNode)

Returns in nodes for a given node.

Parameters
endNodeThe node for which the incoming edges are checked.
Returns
A vector of the connected nodes.

◆ getNumberOfNodes()

uint switchboard::Graph::getNumberOfNodes ( ) const

Returns the number of nodes in the graph.

Returns
The number of nodes.

◆ getOutNodes()

const vector< uint > & switchboard::Graph::getOutNodes ( const uint startNode)

Returns out nodes for a given node.

Parameters
startNodeThe node for which the outgoing edges are checked.
Returns
A vector of the connected nodes.

◆ isCyclic()

bool switchboard::Graph::isCyclic ( )

Checks whether the graph is cyclic.

Returns
True if the graph is cyclic, false otherwise.

◆ removeEdge()

bool switchboard::Graph::removeEdge ( const uint startNode,
const uint endNode )

Removes an edge from between two nodes.

Parameters
startNodeThe start node.
endNodeThe end node.
Returns
True if edge was removed successfully, false otherwise.

◆ removeNode()

bool switchboard::Graph::removeNode ( uint node)

Removes a node from the graph.

Parameters
nodeThe ID of the node to be removed.
Returns
True if the removal was successful, false otherwise.