static void MarkPaintWindows(HWND hwnd, BOOL shouldPaint, LWPAINTSTRUCT *ps) { HWND wp; setNodeVisited(hwnd); if (shouldPaint) { if (CheckOverlapRect(&hwnd->winrect, &ps->wndRect)) { hwnd->shouldPaint = TRUE; } } else { hwnd->shouldPaint = FALSE; } wp = Parent(hwnd); if (wp) { if (!isNodeVisited(wp)) { if (isWindowOpaque(hwnd)) MarkPaintWindows(wp, FALSE, ps); else MarkPaintWindows(wp, shouldPaint, ps); } } wp = NextSibling(hwnd); if (wp) { if (!isNodeVisited(wp)) { if (isWindowOpaque(hwnd) && IsRectAInRectB(&ps->wndRect, &hwnd->winrect)) MarkPaintWindows(wp, FALSE, ps); else MarkPaintWindows(wp, shouldPaint, ps); } } wp = Children(hwnd); if (wp) { if (!isNodeVisited(wp)) { if (hwnd != rootwp) MarkPaintWindows(wp, hwnd->shouldPaint, ps); else MarkPaintWindows(wp, TRUE, ps); } } }
void Graph::doPrim( unsigned int originNode) { int debug; int i; // initialize the 2d vector of [numNodes][2] ints. (nodenumber, weight) will be stored as we compute the prim solution mst_result mst_for_graph(m_totalNumVerticies, std::vector<int> (2)); std::cout << "Starting Prim MST algorithm for " << m_totalNumVerticies << " nodes..."; // std::cin >> debug; // initialize the solution for(i=0; i<m_totalNumVerticies; i++) { mst_for_graph[i][NODENUM_IDX]=(-1); } // add the origin node to the solved set mst_for_graph[0][NODENUM_IDX] = originNode; mst_for_graph[0][EDGEWEIGHT_IDX] = 0; setNodeVisited(originNode); int solution_points_found=1; // now build the MST while iterating through the graph for(i=(m_totalNumVerticies-1); i>0; i--) { unsigned int lowest_cost_edge_this_iteration = 100; // the lowest cost and node for this iteration unsigned int lowest_cost_node_this_iteration = (-1); std::cout << "iterating through the mst solution " << i << " more nodes left in graph" << std::endl; // std::cin >> debug; for(int j=0; j<solution_points_found; j++) { std::cout << "looking at solution location " << j << " node: " << mst_for_graph[j][NODENUM_IDX] << std::endl; // std::cin >> debug; // find the node info for the node being examined (this lookup cannot fail) node_type::iterator itNode=graphNodes.find(mst_for_graph[j][NODENUM_IDX]); std::cout << "examining the edges connected to node: " << itNode->second->m_nodeNumber << std::endl; // std::cin >> debug; // look through the edges of all the nodes in the solution so far for(edge_type::iterator itEdge=itNode->second->m_edges.begin(); itEdge != itNode->second->m_edges.end(); ++itEdge) { std::cout << "found edge to other node: " << itEdge->first << std::endl; // std::cin >> debug; if(isNodeVisited(itEdge->first)) { std::cout << "***node is already in solution, skipping" << std::endl; continue; } std::cout << "now checking if this is the lowest cost: " << (itEdge->second) << std::endl; std::cout << "lowest_cost_edge_this_iteration: " << lowest_cost_edge_this_iteration << std::endl; // now check if its the lowest cost if((itEdge->second) < lowest_cost_edge_this_iteration) { std::cout << "**new lowest code node found: Node: " << itEdge->first << " cost: " << itEdge->second << std::endl; lowest_cost_edge_this_iteration = itEdge->second; lowest_cost_node_this_iteration = itEdge->first; } } } std::cout << "\n==== adding node " << lowest_cost_node_this_iteration << " to solution" << " with a cost of " << lowest_cost_edge_this_iteration << std::endl; // std::cin >> debug; // add a newly found lowest node to the solution mst_for_graph[solution_points_found][NODENUM_IDX] = lowest_cost_node_this_iteration; mst_for_graph[solution_points_found][EDGEWEIGHT_IDX] = lowest_cost_edge_this_iteration; setNodeVisited(lowest_cost_node_this_iteration); solution_points_found++; } std::cout << "----------- MST path ---------------" << std::endl; unsigned int mst_total_cost = 0; for(i=0; i<solution_points_found; i++) { std::cout << "Node: " << mst_for_graph[i][NODENUM_IDX] << " \t" << " Cost: " << mst_for_graph[i][EDGEWEIGHT_IDX] <<std::endl; mst_total_cost += mst_for_graph[i][EDGEWEIGHT_IDX]; } std::cout << "Total MST cost: " << mst_total_cost << std::endl; }