template<class NodeType, class EdgeType>
slang::netlist::DirectedGraph class

A directed graph. Nodes and edges are stored in an adjacency list data structure, where the DirectedGraph contains a vector of nodes, and each node contains a vector of directed edges to other nodes. Multi-edges are not permitted.

Public types

using NodePtrType = std::unique_ptr<NodeType>
using NodeListType = std::vector<NodePtrType>
using iterator = typename NodeListType::iterator
using const_iterator = typename NodeListType::const_iterator
using node_descriptor = size_t
using edge_descriptor = EdgeType*
using DirectedGraphType = DirectedGraph<NodeType, EdgeType>

Public static variables

static const size_t null_node

Constructors, destructors, conversion operators

DirectedGraph() defaulted

Public functions

auto begin() const -> const_iterator
auto end() const -> const_iterator
auto begin() -> iterator
auto end() -> iterator
auto findNode(const NodeType& nodeToFind) const -> node_descriptor
auto getNode(node_descriptor node) const -> NodeType&
Given a node descriptor, return the node by reference.
auto addNode() -> NodeType&
Add a node to the graph and return a reference to it.
auto addNode(std::unique_ptr<NodeType> node) -> NodeType&
Add an existing node to the graph and return a reference to it.
auto removeNode(NodeType& nodeToRemove) -> bool
auto addEdge(NodeType& sourceNode, NodeType& targetNode) -> EdgeType&
Add an edge between two existing nodes in the graph.
auto removeEdge(NodeType& sourceNode, NodeType& targetNode) -> bool
auto outDegree(const NodeType& node) const -> size_t
Return the number of edges outgoing from the specified node.
auto inDegree(const NodeType& node) const -> size_t
Return the number of edges incident to the specified node.
auto numNodes() const -> size_t
Return the size of the graph.
auto numEdges() const -> size_t
Return the number of edges in the graph.

Protected variables

NodeListType nodes

Function documentation

template<class NodeType, class EdgeType>
bool slang::netlist::DirectedGraph<NodeType, EdgeType>::removeNode(NodeType& nodeToRemove)

Remove the specified node from the graph, including all edges that are incident upon this node, and all edges that are outgoing from this node. Return true if the node exists and was removed and false if it didn't exist.

template<class NodeType, class EdgeType>
bool slang::netlist::DirectedGraph<NodeType, EdgeType>::removeEdge(NodeType& sourceNode, NodeType& targetNode)

Remove an edge between the two specified vertices. Return true if the edge exists and was removed, and false if it didn't exist.