码迷,mamicode.com
首页 >  
搜索关键字:moral graph    ( 3648个结果
PAT 1021. Deepest Root (25)
1021. Deepest Root (25) A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you
分类:其他好文   时间:2016-03-02 22:08:53    阅读次数:229
bzoj3639: Query on a tree VII
Description You are given a tree (an acyclic undirected connected graph) with n nodes. The tree nodes are numbered from 1 to n. Each node has a color,
分类:其他好文   时间:2016-02-29 21:30:13    阅读次数:434
bzoj3637: Query on a tree VI
Description You are given a tree (an acyclic undirected connected graph) with n nodes. The tree nodes are numbered from 1 to n. Each node has a color,
分类:其他好文   时间:2016-02-29 21:22:40    阅读次数:224
UVA11387 - The 3-Regular Graph(推理)
题目链接 题意:给n个点,问能否画出一个无向图。且每一个顶点连接3条边。假设能够的话输出连接的边。 思路:当添加一条边时,总的无向图的度数会添加2,所以度数之和n*2为偶数。当n为奇数时,度数之和为奇数,所以不存在。当n为偶数时才符合条件。注意特判n为2时的情况。输出的话,就头尾相连,然后i与i+(
分类:其他好文   时间:2016-02-29 09:21:21    阅读次数:156
networkx学习笔记
编写检验网络的匹配特性的程序时,涉及到节点的强度(与节点相连边的权重和)这个概念,后才明白nx.degree()还有如此强大的功能。 直接上例子: import networkx as nxG=nx.Graph()G.add_edge(1,2, weight=1)G.add_edge(1,3, we
分类:Web程序   时间:2016-02-27 22:04:41    阅读次数:193
SPOJ QTREE 树链剖分
375. Query on a tree Problem code: QTREE You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.
分类:其他好文   时间:2016-02-27 17:55:11    阅读次数:151
hdu 5631 Rikka with Graph(图)
n个点最少要n-1条边才能连通,可以删除一条边,最多删除2条边,然后枚举删除的1条边或2条边,用并查集判断是否连通,时间复杂度为O(n^3) 这边犯了个错误, for(int i=0;i<N;i++){ fa[i]=i; } 这个将i<=N,导致错误,值得注意 AC代码: 1 #pragma com
分类:其他好文   时间:2016-02-26 21:55:46    阅读次数:366
Course Schedule II; BFS; DFS;
We can use bfs to solve this problem; By traverse the prerequisites array, we can generate two graph representations. One is an array of list of out n
分类:其他好文   时间:2016-02-23 08:24:58    阅读次数:148
图论及其应用——树
在之前初步介绍图的文章中,我们得知,图(graph)是表征事物之间关系的一种抽象化表示方法,而基于图的概念,我们将所有的无回路无向图拿出来,给它们一个新的名字——树。 关于树的概念性术语很多,这里我们先就简单的二叉树(一个根至多有两个子树)来进行分析。 这就是一些简单的二叉树,这里A、B、C等我们成
分类:其他好文   时间:2016-02-21 22:37:45    阅读次数:231
HDU 5631 Rikka with Graph
如果原图不连通,直接输出0. 如果原图连通,删除X条边之后要保证新图连通,再看数据是n+1条边-->因此,最多只能删去两条边。 因为n=100,可以枚举进行验证,枚举删去每一条边是否连通,枚举删去每两条边是否连通,验证是否连通可以用并查集,可以BFS。 #include<cstdio> #inclu
分类:其他好文   时间:2016-02-21 21:19:54    阅读次数:288
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!