Internals: Template GraphAlg to allow const. No functional change.
This commit is contained in:
parent
84562f98de
commit
de81593e98
|
|
@ -74,7 +74,7 @@ void V3Graph::deleteCutableOnlyEdges() {
|
|||
//######################################################################
|
||||
// Algorithms - weakly connected components
|
||||
|
||||
class GraphRemoveRedundant : GraphAlg {
|
||||
class GraphRemoveRedundant : GraphAlg<> {
|
||||
bool m_sumWeights; ///< Sum, rather then maximize weights
|
||||
private:
|
||||
void main() {
|
||||
|
|
@ -138,7 +138,7 @@ void V3Graph::removeRedundantEdgesSum(V3EdgeFuncP edgeFuncp) {
|
|||
//######################################################################
|
||||
// Algorithms - weakly connected components
|
||||
|
||||
class GraphAlgWeakly : GraphAlg {
|
||||
class GraphAlgWeakly : GraphAlg<> {
|
||||
private:
|
||||
void main() {
|
||||
// Initialize state
|
||||
|
|
@ -183,7 +183,7 @@ void V3Graph::weaklyConnected(V3EdgeFuncP edgeFuncp) {
|
|||
//######################################################################
|
||||
// Algorithms - strongly connected components
|
||||
|
||||
class GraphAlgStrongly : GraphAlg {
|
||||
class GraphAlgStrongly : GraphAlg<> {
|
||||
private:
|
||||
uint32_t m_currentDfs; // DFS count
|
||||
std::vector<V3GraphVertex*> m_callTrace; // List of everything we hit processing so far
|
||||
|
|
@ -269,7 +269,7 @@ void V3Graph::stronglyConnected(V3EdgeFuncP edgeFuncp) {
|
|||
//######################################################################
|
||||
// Algorithms - ranking
|
||||
|
||||
class GraphAlgRank : GraphAlg {
|
||||
class GraphAlgRank : GraphAlg<> {
|
||||
private:
|
||||
void main() {
|
||||
// Rank each vertex, ignoring cutable edges
|
||||
|
|
@ -325,7 +325,7 @@ void V3Graph::rank(V3EdgeFuncP edgeFuncp) {
|
|||
//######################################################################
|
||||
// Algorithms - ranking
|
||||
|
||||
class GraphAlgRLoops : GraphAlg {
|
||||
class GraphAlgRLoops : GraphAlg<> {
|
||||
private:
|
||||
std::vector<V3GraphVertex*> m_callTrace; // List of everything we hit processing so far
|
||||
bool m_done; // Exit algorithm
|
||||
|
|
@ -381,7 +381,7 @@ void V3Graph::reportLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp) {
|
|||
//######################################################################
|
||||
// Algorithms - subtrees
|
||||
|
||||
class GraphAlgSubtrees : GraphAlg {
|
||||
class GraphAlgSubtrees : GraphAlg<> {
|
||||
private:
|
||||
V3Graph* m_loopGraphp;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,17 +30,19 @@
|
|||
// Algorithms - common class
|
||||
// For internal use, most graph algorithms use this as a base class
|
||||
|
||||
template <class T = V3Graph> // Or sometimes const V3Graph
|
||||
class GraphAlg {
|
||||
protected:
|
||||
V3Graph* m_graphp; // Graph we're operating upon
|
||||
V3EdgeFuncP m_edgeFuncp; // Function that says we follow this edge
|
||||
|
||||
inline bool followEdge(V3GraphEdge* edgep) {
|
||||
return (edgep->weight() && (m_edgeFuncp)(edgep));
|
||||
}
|
||||
GraphAlg(V3Graph* graphp, V3EdgeFuncP edgeFuncp)
|
||||
: m_graphp(graphp), m_edgeFuncp(edgeFuncp) {}
|
||||
T* m_graphp; // Graph we're operating upon
|
||||
V3EdgeFuncP m_edgeFuncp; // Function that says we follow this edge
|
||||
// CONSTRUCTORS
|
||||
GraphAlg(T* graphp, V3EdgeFuncP edgeFuncp)
|
||||
: m_graphp(graphp), m_edgeFuncp(edgeFuncp) {}
|
||||
~GraphAlg() {}
|
||||
// METHODS
|
||||
inline bool followEdge(V3GraphEdge* edgep) {
|
||||
return (edgep->weight() && (m_edgeFuncp)(edgep));
|
||||
}
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ DfaVertex* DfaGraph::findStart() {
|
|||
// Algorithms - convert NFA to a DFA
|
||||
// Uses the Subset Construction Algorithm
|
||||
|
||||
class GraphNfaToDfa : GraphAlg {
|
||||
class GraphNfaToDfa : GraphAlg<> {
|
||||
// We have two types of nodes in one graph, NFA and DFA nodes.
|
||||
// Edges from NFA to NFA come from the user, and indicate input or epsilon transitions
|
||||
// Edges from DFA to NFA indicate the NFA from which that DFA was formed.
|
||||
|
|
@ -363,7 +363,7 @@ void DfaGraph::nfaToDfa() {
|
|||
//
|
||||
// Scan the DFA, cleaning up trailing states.
|
||||
|
||||
class DfaGraphReduce : GraphAlg {
|
||||
class DfaGraphReduce : GraphAlg<> {
|
||||
private:
|
||||
// METHODS
|
||||
static int debug() { return 0; }
|
||||
|
|
@ -505,7 +505,7 @@ void DfaGraph::dfaReduce() {
|
|||
// The user's old accept is now the new accept. This is imporant as
|
||||
// we want the virtual type of it to be intact.
|
||||
|
||||
class DfaGraphComplement : GraphAlg {
|
||||
class DfaGraphComplement : GraphAlg<> {
|
||||
private:
|
||||
// MEMBERS
|
||||
DfaVertex* m_tempNewerReject;
|
||||
|
|
|
|||
Loading…
Reference in New Issue