智乐兔

算法与数据结构

  • 克鲁斯卡尔最小生成树 Java 代码

    克鲁斯卡尔最小生成树 Java 代码

    克鲁斯卡尔最小生成树 Java 代码 import java.io.*;import java.util.*;public class Kruskal {  private final int MAX_NODES = 21;  private HashSet nodes[];               // Array of connected components  private TreeSet allEdges ...

    查看全文

  • 克鲁斯卡尔最小生成树 C 代码

    克鲁斯卡尔最小生成树 C 代码

    克鲁斯卡尔最小生成树 C 代码 #include<stdio.h>#include<stdlib.h>void printArray(int a[][100],int n);void AdjacencyMatrix(int a[][100], int n){    int i,j;    for(i = 0;i < n; i++)    {        for(j = 0;j < i; j+ ...

    查看全文

  • Floyd-Warshall最短路径 C++ 代码

    Floyd-Warshall最短路径 C++ 代码

    Floyd-Warshall最短路径 C++ 代码 #include<iostream.h>#include<conio.h>#include<stdio.h>#include<stdlib.h>class path{    int n;        int p[10][10];        int a[10][10];     ...

    查看全文

  • Floyd-Warshall最短路径 C 代码

    Floyd-Warshall最短路径 C 代码

    Floyd-Warshall最短路径 C 代码 // Floyd-Warshall algorithm// //  solves the all-pairs shortest path problem using Floyd-Warshall algorithm//  inputs:  nn, number of nodes//           connectivity matrix cmat, where 0 means disconnected//& ...

    查看全文

  • 拓扑排序(深度优先) C++ 代码

    拓扑排序(深度优先) C++ 代码

    拓扑排序(深度优先) C++ 代码 vector<int>g[N];//邻接表存储int vis[N],topo[N],cnt;bool dfs(int u){    vis[u] = -1;//-1用来表示顶点u正在访问    for(int i = 0 ; i < g[u].size() ; i ++)    {        if(vis[g[u][i]] == -1)//表示这个点进入了两次,肯定出现了 ...

    查看全文

  • 拓扑排序(深度优先) C 代码

    拓扑排序(深度优先) C 代码

    拓扑排序(深度优先) C 代码 #include<stdio.h>const long maxv=108;long v,e,count,a[maxv],used[maxv];bool g[maxv][maxv],ans;void init(){    scanf("%ld%ld",&v,&e);    for(long i=1;i<=v;i++)      for(long j=1;j<=v;j++)   & ...

    查看全文

  • 拓扑排序 C++ 代码

    拓扑排序 C++ 代码

    拓扑排序 C++ 代码 /**Program:TopologicalSort*Author:Yee-fan Zhu*/#include <fstream>using namespace std;ifstream fin("topo.in");ofstream fout("topo.out");bool TopologicalSort(int a[][101],int *ans) //可以完成拓扑排序则返回True   {        int n = a[0][0], i, j;  & ...

    查看全文

  • 拓扑排序 C 代码

    拓扑排序 C 代码

    拓扑排序 C 代码 /*  topsort.c    Topologically sort a directed acyclic graph (DAG)    by: Steven Skiena    begun: March 26, 2002*//*Copyright 2003 by Steven S. Skiena; all rights reserved. Permission is granted for use in non-commerical applicationspro ...

    查看全文

  • 连通图 C 代码

    连通图 C 代码

    连通图 C 代码 /*  connected.c    Compute the connected components of a graph.    by: Steven Skiena    begun: March 6, 2002*//*Copyright 2003 by Steven S. Skiena; all rights reserved. Permission is granted for use in non-commerical applicationsprovided ...

    查看全文

  • 深度优先搜索 C 代码

    深度优先搜索 C 代码

    深度优先搜索 C 代码 /*  bfs-dfs.c    A generic implementation of graph traversal: breadth-first    and depth-first search    begun: March 27, 2002    by: Steven Skiena*//*Copyright 2003 by Steven S. Skiena; all rights reserved. Permission ...

    查看全文

  • 广度优先搜索 C++ 代码

    广度优先搜索 C++ 代码

    广度优先搜索 C++ 代码 #include <iostream>using namespace std;struct node {int info;node *next;};class Queue {public:Queue();~Queue();bool isEmpty();void add(int);int get();private:node *first, *last;};class Graph {public:Graph(int size = 2);~Graph();bool isConnected(int, int);// adds the (x, y) pa ...

    查看全文

  • 广度优先搜索 C 代码

    广度优先搜索 C 代码

    广度优先搜索 C 代码 /*  bfs-dfs.c    A generic implementation of graph traversal: breadth-first    and depth-first search    begun: March 27, 2002    by: Steven Skiena*//*Copyright 2003 by Steven S. Skiena; all rights reserved. Permission ...

    查看全文

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微