码迷,mamicode.com
首页 >  
搜索关键字:edges    ( 333个结果
K短路【模板】
A*+SPFA算法: (1)将有向图的所有边正向、反向分别存入两个不同的边集(Edges,Edges1)中。用反向边集,以所求终点t为源点,利用SPFA或Dijkstra求解出所有点到t的最短路径,用Dist[i]数组来表示点i到点t的最短距离。 (2)建立一个优先队列,将源点s加入到队列中。 (3)从优先队列中取出最小的点p,如果点p == t,则计算t出队的次数。如果当前路径长度就是s到t...
分类:其他好文   时间:2015-05-05 00:09:25    阅读次数:128
最小生成树【模板】
Kruskal算法struct Edge { int from; int to; int w; }; Edge Edges[200200]; int father[200200],N,M; int find(int x) { if(x != father[x]) father[x] = find(father[x]...
分类:其他好文   时间:2015-05-03 00:51:15    阅读次数:211
HDU 3478 Catch(判断奇数环)
Description A thief is running away!  We can consider the city where he locates as an undirected graph in which nodes stand for crosses and edges stand for streets. The crosses are labeled from 0 ...
分类:其他好文   时间:2015-05-02 22:06:46    阅读次数:204
第四届华中区程序设计邀请赛暨武汉大学第十三届校赛 网络预选赛 Problem 1566 - C - Spanning Tree
Description You are given a graph with N nodes and M edges.  Then every time you are required to add an additional edge with weight Wi connecting the node Ai and Bi in the graph, and then calculat...
分类:其他好文   时间:2015-04-22 09:40:45    阅读次数:140
Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water....
分类:其他好文   时间:2015-04-09 10:41:17    阅读次数:185
hihoCoder #1087 Hamiltonian Cycle
DescriptionGiven a directed graph containing n vertice (numbered from 1 to n) and m edges. Can you tell us how many different Hamiltonian Cycles are t...
分类:其他好文   时间:2015-04-06 21:34:45    阅读次数:144
BZOJ 1083: [SCOI2005]繁忙的都市(MST)
裸的最小生成树..直接跑就行了----------------------------------------------------------------------#include#include#include#define rep(i,n) for(int i=0;i edges; vo....
分类:其他好文   时间:2015-03-22 00:12:44    阅读次数:155
Codeforces 91C Ski Base 加边求欧拉回路数量
题目链接:点击打开链接 题意: 给出n个点m条无向边的图 开始图里没有边,每次加一条边,然后输出图里欧拉回路的条数。 思路: We will count the number of ski bases including the base consisted of empty subset of edges (before printing just subtract one)....
分类:其他好文   时间:2015-03-18 23:21:31    阅读次数:233
JavaScript实现图的深度广度优先遍历
function Graph(v) { this.vertices = v; //初始化顶点 this.edges = 0; //边数先设置为0 this.adj = []; //为每一个顶点准备一个链表,表示它和所有节点的关系 for (var i = 0...
分类:编程语言   时间:2015-03-18 17:42:17    阅读次数:377
poj 3237 Tree 树链剖分
题目链接:http://poj.org/problem?id=3237You are given a tree withNnodes. The tree’s nodes are numbered 1 throughNand its edges are numbered 1 throughN? 1. ...
分类:其他好文   时间:2015-03-17 19:39:28    阅读次数:182
333条   上一页 1 ... 27 28 29 30 31 ... 34 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!