嗅谱网

  • 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 ...

    查看全文

  • 歪斜堆 C++ 代码

    歪斜堆 C++ 代码

    歪斜堆 C++ 代码 /******************************************************************************* File: SkewBinomialHeap.hh* Author: Keith Schwarz (htiek@cs.stanford.edu)** An implementation of a priority queue backed by a skew binomial heap.  Like* regular binomial heaps, skew binomial heaps are ...

    查看全文

  • 左倾堆 C 代码

    左倾堆 C 代码

    左倾堆 C 代码         #include "leftheap.h"        #include "fatal.h"        #include <stdlib.h>        struct TreeNode       ...

    查看全文

  • 斐波那契堆 Java 代码

    斐波那契堆 Java 代码

    斐波那契堆 Java 代码 /**   * Licensed to the Apache Software Foundation (ASF) under one or more   * contributor license agreements.  See the NOTICE file distributed with   * this work for additional information regarding copyright ownership.   * The ASF lice ...

    查看全文