[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=2454 [别人博客粘贴过来的] 博客地址:https://www.cnblogs.com/debugcool/archive/2011/04/23/HDOJ2454.html 一句话,顶点的度序列 Havel 定理~ 定义:给出一个无向图的顶点度序列 {dn},要求判断能否构造出一个简单无向图. 分析: 贪心的方法是每次把顶点按度大小从大到小排序,取出度最大的点Vi,依次和度较大的那些顶点Vj连接…
主题链接:pid=2454">http://acm.hdu.edu.cn/showproblem.php?pid=2454 Problem Description Wang Haiyang is a strong and optimistic Chinese youngster. Although born and brought up in the northern inland city Harbin, he has deep love and yearns for the bound…
Problem Description Wang Haiyang is a strong and optimistic Chinese youngster. Although born and brought up in the northern inland city Harbin, he has deep love and yearns for the boundless oceans. After graduation, he came to a coastal city and got…
传送门 参考资料: [1]:图论-度序列可图性判断(Havel-Hakimi定理) •题意 给你 n 个非负整数列,判断这个序列是否为可简单图化的: •知识支持 握手定理:在任何无向图中,所有顶点的度数之和等于边数的2倍: 推论:任何图,奇度顶点的个数为偶数: 可图化定理:非负整数序列 $d={d_1,d_2,\cdots,d_n}$ 是可图化的当且仅当 $\sum_{i=1}^{i \leq n}d_i$ 为偶数: 简单图:既不含平行边,也不含环: 平行边:在无向图中,如果关联一对顶点的无向边…
题意 给你一个度序列,问能否构成一个简单图. 分析 对于可图化,只要满足度数之和是偶数,即满足握手定理. 对于可简单图化,就是Heavel定理了. Heavel定理:把度序列排成不增序,即 $deg[1] \geq deg[2] \geq ... \geq deg[V]$,则 $deg$ 可简单图化当且仅当 ${deg}' = \{deg[2]-1, deg[3]-1,...,deg[deg[1]+1]-1,...,deg[v] \}$ 可简单图化. 简单地说,把 $deg$ 从大到小排序后,找…
///已知各点的度,推断是否为一个简单图 #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; int a[1010]; bool cmp(int x,int y) { return x>y; } int main() { int t,n,i,j; scanf("%d",&t); while(t--) { int flag=1; sca…
传送门 •Havel-Hakimi定理: 给定一个非负整数序列{d1,d2,...dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化. 进一步,若图为简单图,则称此序列可简单图化. 定理描述: 由非负整数组成的有限非递增序列,S={d1,d2,d3...dn},当且仅当S1={d2-1,d3-1...d(d1+1),d(d1+2)......dn}也是可图的, 也就是说,序列S1也是由非负整数组成的有限非递增序列,S1是由S的删除第一个元素d1之后的前d1个元素分别减一后…
题目链接 /* *题目大意: *给出一个图的每个点的度的序列,求能否构成一个简单图,如果能构出简单图,则输出图的邻接矩阵; * *算法思想: *Havel定理的应用; *给定一个非负整数序列{dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化; *若图为简单图,则称此序列可简单图化; * *可图化的判定: *d1+d2+……dn==0(mod 2); * *处理过程: *每次处理度数最大的点,设其度数为d则将他与度数最大的d个点(不含自己)个连一条边(若该点度数大于0),…
http://acm.uestc.edu.cn/#/problem/show/913 握手 Time Limit: 2000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status 一群人参加了一次聚会,其中有一些人是好朋友.一对朋友见面后握手且仅握一次手,并且每个人不会和自己握手(废话!).现在告诉你每个人一共握了几次手,请你判断是否存在一种朋友关系满足每个人的握手数. Input 输入多…
题意:根据图的度数列构造图 分析:该题可根据Havel定理来构造图.Havel定理对可图化的判定: 把序列排成不增序,即d1>=d2>=……>=dn,则d可简单图化当且仅当d’={d2-1,d3-1,……d(d1+1)-1, d(d1+2),d(d1+3),……dn}可简单图化.简单的说,把d排序后,找出度最大的点(设度为d1),把它与度次大的d1个点之间连边,然后这个点就可以不管了,一直继续这个过程,直到建出完整的图,或出现负度等明显不合理的情况. #include <cstdi…
给一个无向图的度序列判定是否可图化,并求方案: 可图化的判定:d1+d2+……dn=0(mod 2).关于具体图的构造,我们可以简单地把奇数度的点配对,剩下的全部搞成自环. 可简单图化的判定(Havel定理):把序列排成不增序,即d1>=d2>=……>=dn,则d可简单图化当且仅当d’={d2-1,d3-1,……d(d1+1)-1, d(d1+2),d(d1+3),……dn}可简单图化.简单的说,把d排序后,找出度最大的点(设度为d1),把它与度次大的d1个点之间连边,然后这个点就可以不…
先贴一个百度百科的注释 Havel定理编辑 本词条缺少概述.名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! 中文名 Havel定理 外文名 Canisters theorem 特    点 非负整数序列{dn} 实    质 无向图使得图中各点的度 给定一个非负整数序列{dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化.进一步,若图为简单图,则称此序列可简单图化 可图化的判定:d1+d2+……dn=0(mod 2).关于具体图的构造,我们可以简单地把奇数…
给定一个非负整数序列{dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化.进一步,若图为简单图,则称此序列可简单图化. 此题因为是无自环无重边,所以是简单图.用判定简单图可图化的Havel-Hakimi定理. Havel-Hakimi定理: 一个度序列: 是简单图度序列当且仅当: 是简单图的度序列. 简单来讲,算法流程如下: 设度序列为d1,d2,d3....dn 1.如果度序列中元素有负数或者度序列和不为偶数,则肯定不可图. 2.每次取度序列中最大元素,设为M,如果M>…
http://blog.csdn.net/xcszbdnl/article/details/14174669 代码风格这里的 Frogs' Neighborhood Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 9953   Accepted: 4161   Special Judge Description 未名湖附近共有N个大小湖泊L1, L2, ..., Ln(其中包括未名湖),每个湖泊Li里住着一只青蛙Fi(1…
Graph Reconstruction Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Let there be a simple graph with N vertices but we just know the degree of each vertex. Is it possible to reconstruct the graph only by these information? A sim…
图的度数分布 import collections import matplotlib.pyplot as plt import networkx as nx G = nx.gnp_random_graph(100, 0.02) degree_sequence = sorted([d for n, d in G.degree()], reverse=True) # degree sequence # print "Degree sequence", degree_sequence de…
传送门:https://codeforces.com/gym/100801 题意: 给你一个DAG图,你最多可以进行k次操作,每次操作可以连一条有向边,问你经过连边操作后最小拓扑序的最大值是多少 题解: 最小拓扑序:与普通拓扑序不同的是,用一个小根堆记录入度为0的点做拓扑排序即可 怎么样使得最小拓扑序最大呢?已知拓扑序是入度小的点在前面,那么,如果我们可以使得大的点的度数尽量小或者是小的点度数尽量大就可以使得拓扑序变大了,由于我们只有加边的操作,那么我们可以将边尽量从大的点往小的点去连边 我们定…
POJ1180 Batch Scheduling Description There is a sequence of N jobs to be processed on one machine. The jobs are numbered from 1 to N, so that the sequence is 1,2,..., N. The sequence of jobs must be partitioned into one or more batches, where each ba…
作者简介: 吴天龙  香侬科技researcher 公众号(suanfarensheng) 导言 图(graph)是一个非常常用的数据结构,现实世界中很多很多任务可以描述为图问题,比如社交网络,蛋白体结构,交通路网数据,以及很火的知识图谱等,甚至规则网格结构数据(如图像,视频等)也是图数据的一种特殊形式,因此图是一个很值得研究的领域. 针对graph的研究可以分为三类: 1.经典的graph算法,如生成树算法,最短路径算法,复杂一点的二分图匹配,费用流问题等等: 2.概率图模型,将条件概率表达为…
题意 Language:Default K-Anonymous Sequence Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 6618 Accepted: 2210 Description The explosively increasing network data in various application domains has raised privacy concerns for the individuals…
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is to find i…
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretical analysis of structural and functional systems.[J]. Nature Reviews Neuroscience, 2009, 10(3):186-198. Graph measures A graph G consisting of a set of…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 9139   Accepted: 3794 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ver…
题目地址:http://poj.org/problem?id=2553 The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7881   Accepted: 3263 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finit…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 9641   Accepted: 4008 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ver…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 11981   Accepted: 4931 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ve…
信息学竞赛中,有关生成树的最优化问题如最小生成树等是我们经常遇到的,而对生成树的计数及其相关问题则少有涉及.事实上,生成树的计数是十分有意义的,在许多方面都有着广泛的应用.本文从一道信息学竞赛中出现的例题谈起,首先介绍了一种指数级的动态规划算法,然后介绍了行列式的基本概念.性质,并在此基础上引入Matrix-Tree定理,同时通过与一道数学问题的对比,揭示了该定理所包含的数学思想.最后通过几道例题介绍了生成树的计数在信息学竞赛中的应用,并进行总结. 生成树的计数 Matrix-Tree定理 问题…
Graph Reconstruction Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Let there be a simple graph with N vertices but we just know the degree of each vertex. Is it possible to reconstruct the graph only by these information? A sim…
Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called vertices (or nodes). Let E be a subset of the Cartesian product V×V, its elements being called edges. Then G…
Graph There are two standard ways to represent a graph G=(V,E)G=(V,E), where VV is a set of vertices and EE is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array Ad…