tan  0.0.1
tanlang::DependencyGraph< T > Class Template Reference

Public Member Functions

void add_dependency (T depended, T dependent)
 dependent depends on depended More...
 
std::pair< std::optional< vector< T > >, std::optional< T > > topological_sort () const
 Sort topologically so for no element is dependent on its succeeding element(s). More...
 
int num_dependent (T depended) const
 Number of nodes that depends on depended. More...
 
int num_depended (T dependent) const
 Number of nodes that dependent depends on. More...
 
void clear ()
 

Detailed Description

template<typename T>
class tanlang::DependencyGraph< T >

Definition at line 11 of file dependency_graph.h.

Member Function Documentation

◆ add_dependency()

template<typename T >
void tanlang::DependencyGraph< T >::add_dependency ( depended,
dependent 
)
inline

dependent depends on depended

Definition at line 16 of file dependency_graph.h.

◆ num_depended()

template<typename T >
int tanlang::DependencyGraph< T >::num_depended ( dependent) const
inline

Number of nodes that dependent depends on.

Definition at line 92 of file dependency_graph.h.

Referenced by tanlang::DependencyGraph< T >::topological_sort().

◆ num_dependent()

template<typename T >
int tanlang::DependencyGraph< T >::num_dependent ( depended) const
inline

Number of nodes that depends on depended.

Definition at line 80 of file dependency_graph.h.

◆ topological_sort()

template<typename T >
std::pair<std::optional<vector<T> >, std::optional<T> > tanlang::DependencyGraph< T >::topological_sort ( ) const
inline

Sort topologically so for no element is dependent on its succeeding element(s).

Returns
(res, node)
  • If successful, res is a sorted vector of T and node is nullopt
  • Otherwise, res is nullopt, and node is the node that has cyclic dependency

Definition at line 29 of file dependency_graph.h.

References tanlang::DependencyGraph< T >::num_depended().


The documentation for this class was generated from the following file: