本文整理汇总了C++中Graph::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::GetSize方法的具体用法?C++ Graph::GetSize怎么用?C++ Graph::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::GetSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindWinner
bool FindWinner(Graph &G, EDGECOLOR color){
//adds nodes to adj_list of every edge in graph
for (int i = 0; i < G.GetSize(); i++) {
for (int j = 0; j < G.GetSize(); j++) {
G.matrix[i][j].build_adj(i,j,G);
}
}
//start looking for path
for (int j = 0; j < G.GetSize(); j++) {
if(color == P1){
bool iftrue = look_for_path(G,color,G.matrix[0][j],G.GetSize(),j);
if(iftrue == true){
return true;
}
}
if(color == P2){
bool iftrue = look_for_path(G,color,G.matrix[j][0],G.GetSize(),j);
if(iftrue == true){
return true;
}
}
}
return false;
}
示例2: build_adj
//Finds every edge that the current edge is connected to.
void edge::build_adj(int x, int y, Graph &G){
for(int j = -1; j <= 1; j++){
for(int i = -1; i <= 1; i++){
if(x+i < 0 || x+i >= G.GetSize()){
continue;
}
if(y+j < 0 || y+j >= G.GetSize()){
continue;
}
if(i == 0 && j == 0){
continue;
}
if(i == -1 && j == -1){
continue;
}
if(i == 1 && j== 1){
continue;
}
edge_ref tmp;
tmp.x = x+i;
tmp.y = y+j;
adj_list.push_back(tmp);
}
}
}
示例3: TarjanSCC
TarjanSCC(const Graph &graph) : graph(graph) {
v_index = vector<int>(graph.GetSize(), UNDEFINED);
lowlink = vector<int>(graph.GetSize(), UNDEFINED);
onstack = vector<bool>(graph.GetSize(), false);
index = 0;
S.clear();
// cout << "BEGIN SCC" << endl;
for (int v = 0; v < v_index.size(); v++) {
if (v_index[v] == UNDEFINED)
StrongConnect(v);
}
// cout << "END SCC (we survived recursion)" << endl;
reverse(result.begin(), result.end());
}
示例4: DpSolver
DpSolver(const DFA &dfa, const Graph &graph, unsigned novelty_mask) : dfa(dfa), graph(graph), novelty_mask(novelty_mask) {
statii = {(size_t) graph.GetSize(), Status::MakeInvalid(dfa)};
statii.at(graph.GetStartNode()) = MakeInitialStatus();
scc_by_node = vector<int>(graph.GetSize(), 0);
auto sccs = StronglyConnectedComponents(graph);
int i = 0;
for (const auto &scc : sccs) {
for (int node : scc)
scc_by_node[node] = i;
i++;
}
// cout << scc_by_node << endl;
//cout << sccs << endl;
// for (auto scc : sccs) {
// ShowNodes(scc);
// }
for (const auto &scc : sccs) {
UpdateSCC(scc);
for (int node : scc) {
for (int cmd = 0; cmd < 6; cmd++) {
int node2 = graph.tr[node][cmd];
if (node2 == Graph::COLLISION)
continue;
if (scc_by_node.at(node2) > scc_by_node.at(node)) {
//cout << node << " -> " << node2 << endl;
statii[node2].Merge(statii[node].Translate(cmd, dfa));
//
}
}
}
}
// for (const auto &scc : sccs) {
// cout << "---" << endl;
// for (int node : scc) {
// cout << node << " " << statii[node].score << " " << ChainToVector(statii[node].best) << endl;
// }
// }
}