<< Click to Display Table of Contents >> Navigation: Reference Manual > Learning > DSL_pattern |
Header file: pattern.h
enum EdgeType {None,Undirected,Directed};
Edge type identifiers.
int GetSize() const;
void SetSize(int size);
Gets/sets the number of nodes in the pattern.
EdgeType GetEdge(int from, int to) const;
Returns the edge type between from and to, where from and to are zero-based indices of the nodes in the pattern. If there is no edge, EdgeType::None is returned.
void SetEdge(int from, int to, EdgeType type);
Sets the edge type between from and to, where from and to are zero-based indices of the nodes in the pattern. To remove the edge, set the type parameter to EdgeType::None.
bool HasDirectedPath(int from, int to) const;
Returns true if there is a directed path between from and to, where from and to are zero-based indices of the nodes in the pattern.
bool HasCycle() const;
Returns true if the pattern contains a cycle.
bool IsDAG() const;
Returns true if the pattern is an acyclic directed graph - there are no cycles and all edges are directed.
bool ToDAG();
Attempts the conversion of pattern to an acyclic directed graph. Returns true if successful.
bool ToNetwork(const DSL_dataset &ds, DSL_network &net);
Attempts the conversion of pattern to an acyclic directed graph. If successful, creates DSL_network with node identifiers and outcomes based on the specified data set. It is assumed that the data set was used previously to obtain this pattern, therefore the order of variables in the data set corresponds to the order of nodes in the pattern (and in the resulting network). Returns true if successful.
bool HasIncomingEdge(int to) const;
bool HasOutgoingEdge(int from) const;
Return true if there is an edge incoming or outgoing to/from the specified node.
void GetAdjacentNodes(const int node, std::vector<int>& adj) const;
void GetParents(const int node, std::vector<int>& par) const;
void GetChildren(const int node, std::vector<int>& child) const;
Return the adjacent/parent/children nodes of the specified node.