voidDFS(ALGraph G,int v){
visited[v]=1;printf("%c ", G.vertices[v].data);for(ArcNode* cur = G.vertices[v].firstarc; cur !=nullptr; cur = cur->nextarc){if(!visited[cur->adjvex])DFS(G, cur->adjvex);}}
2.非递归
#include<stack>#include<iostream>usingnamespace std;voidDFS(ALGraph G,int v){
visited[v]=1;printf("%c ", G.vertices[v].data);
stack<ArcNode*> st;
ArcNode* cur = G.vertices[v].firstarc;int index =0;while(cur ||!st.empty()){while(cur){
index = cur->adjvex;if(!visited[index]){
st.push(cur);
visited[index]=1;printf("%c ", G.vertices[index].data);
cur = G.vertices[index].firstarc;}else
cur = cur->nextarc;}if(st.empty())break;
cur = st.top();
st.pop();
cur = cur->nextarc;}}
在 Windows 操作系统中,原生提供了强大的网络编程支持,允许开发者使用 Socket API 进行网络通信,通过 Socket API,开发者可以创建、连接、发送和接收数据,实现网络通信。本文将深入探讨如何通过调用原生网络 API 实现同…
gramm (complete data visualization toolbox, ggplot2/R-like)
来源:Morel, Pierre. “Gramm: Grammar of Graphics Plotting in Matlab.” The Journal of Open Source Software, vol. 3, no. 23, The Open Journal, Mar. 2018, p. 568, doi:10.21105/joss.00568…