Data Structures and Algorithms (English) - 6-14 Count Connected Components(20 分)

简介: Data Structures and Algorithms (English) - 6-14 Count Connected Components(20 分)

题目链接:点击打开链接

题目大意:略。

解题思路:略。

AC 代码

intvis[MaxVertexNum];
voiddfs(LGraphGraph, intv)
{
vis[v]=1;
PtrToAdjVNodep=Graph->G[v].FirstEdge;
while(p)
    {
inti=p->AdjV;
if(!vis[i]) dfs(Graph,i);
p=p->Next;
    }
}
intCountConnectedComponents( LGraphGraph )
{
intcnt=0;
for(inti=0;i<Graph->Nv;i++) vis[i]=0;
for(inti=0;i<Graph->Nv;i++)
if(!vis[i])
        {
dfs(Graph,i);
cnt++;
        }
returncnt;
}
目录
相关文章
|
数据可视化 数据挖掘 开发者
Data-Basic Statistical Descriptions of Data| 学习笔记
快速学习 Data-Basic Statistical Descriptions of Data。
105 0
Data-Basic Statistical Descriptions of Data| 学习笔记
Data Structures and Algorithms (English) - 7-8 File Transfer(25 分)
Data Structures and Algorithms (English) - 7-8 File Transfer(25 分)
85 0
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
89 0
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
166 0
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
85 0
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
119 0
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
87 0
Data Structures and Algorithms (English) - 6-6 Level-order Traversal(25 分)
Data Structures and Algorithms (English) - 6-6 Level-order Traversal(25 分)
85 0
Data Structures and Algorithms (English) - 6-7 Isomorphic(20 分)
Data Structures and Algorithms (English) - 6-7 Isomorphic(20 分)
105 0
Data Structures and Algorithms (English) - 7-10 Saving James Bond - Easy Version(25 分)
Data Structures and Algorithms (English) - 7-10 Saving James Bond - Easy Version(25 分)
68 0