![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
AI_Mathworker
本人现于山东大学数学学院攻读信息与计算科学学位,入门计算机,对数据分析与挖掘尤感兴趣,仅以此记录和分享学习的点点滴滴,如有纰漏,不吝赐教。
展开
-
BGLL算法 C++实现
实际上,BGLL算法就是在CNM算法的基础之上,再进一步,通过将CNM算法的结果中处于同一个社团的节点看作一个节点,再使用CNM算法进行社团划分,照此步骤反复迭代,每一次迭代记作一个pass,直到无法继续划分为止(就是在节点合并后,Q也不再增加)。从而尽量减轻因CNM算法的贪心策略造成的社团划分效果不佳,CNM算法实现可参考前文《CNM算法C++实现》下文示例数据下载链接:facebook_c...原创 2020-01-08 12:11:10 · 840 阅读 · 5 评论 -
幂法求矩阵最大特征值及其对应的特征向量 C++实现
#include<iostream>#include<cstring>#include<algorithm>#include<math.h>#define N 1100using namespace std;int n,flag;float m,next_m,eclipse,sum,A[N][N],z[N],y[N],next_z[N...原创 2020-01-08 11:52:40 · 3790 阅读 · 0 评论 -
CNM算法C++实现
博主第一次写社团划分的算法,原本CNM算法应该是通过维护一个大根堆来实现的,因为对这个算法还没那么熟,所以用的普通方法和邻接矩阵来实现的。不过不管怎么说,算法的基于贪婪策略,根据模块度划分社团的核心思想一定是不变的。公式的话,应该已经有不少文章介绍,大家可以参考,我就只贴代码了。#include<iostream>#include<cstring>#define ...原创 2020-01-06 15:08:28 · 3287 阅读 · 0 评论 -
最小费用最大流(Bellman-Ford)C++实现
#include <iostream>#include <queue>#include <vector>#include <algorithm>using namespace std;#define N 1010typedef struct edge{ int from; int to; int cap; int flow;...原创 2019-09-12 20:00:53 · 839 阅读 · 0 评论 -
UVa1592 Database
为每个字符串标号(利用vector和map实现string->int的转换),然后再遍历之。#include <iostream>#include <map>#include <string>#include<utility>#include <vector>#include <set>using na...原创 2019-09-07 18:18:08 · 163 阅读 · 0 评论 -
FBI树(先递归构建二叉树,再后序遍历之)
#include <iostream>#include <algorithm>#include <math.h>using namespace std;#define N 1200char arrr[N];int arr[N];typedef struct S{ char type; S *lchild; S *rchild;}tree...原创 2019-08-15 23:22:42 · 216 阅读 · 0 评论 -
C++无向图判断是否存在回路。(并查集的思想)
参考王红梅、胡明、王涛编著的《数据结构(C++版)》中的思想,采用并查集判断无向图是否存在回路。//无向图判断是否有环路。#include <iostream>using namespace std;#define N 1000typedef struct edge{ int from; int to; int weight;};edge A[N];int...原创 2019-08-11 09:25:03 · 1698 阅读 · 0 评论 -
【NOIP2012普及】质因数分解
唯一分解定理的应用。#include <iostream>using namespace std;int main(){ long int n; int i; cin >> n; for (i = 2; i*i <= n; i++) if (n%i == 0) break; cout << n / i << en...原创 2019-08-14 22:45:23 · 237 阅读 · 0 评论 -
C++实现Floyd算法(路径+长度)
Floyd多源最短路,时间复杂度为O(n^3)。#include <iostream>#include <string>#include <stack>using namespace std;#define N 1000int dist[N][N];int A[N][N];int path[N][N];stack<int> Q...原创 2019-08-08 20:15:22 · 805 阅读 · 0 评论 -
C++实现Bellman-Ford算法(长度+路径)
Bellman-Ford算法适用于不含负环路的图,比Dijkstra适用范围广。但是时间复杂度为O(n^3)。#include <iostream>#include <math.h>#include <stack>using namespace std;#define N = 1000stack<int> Q;int path[N...原创 2019-08-08 20:06:56 · 682 阅读 · 0 评论 -
C++实现Dijkstra算法(长度+路径)
Dijkstra只适用于非负权图(因为每循环一步就直接把未标号点集中路径最短的点标号,这样的话如果有负权图,是完全可能在下一步循环中使这条路径变短的),路径的话可以在循环中记录每个结点的前驱结点,最后用栈输出出来。#include <iostream>#include <stack>using namespace std;#define N 1000int ...原创 2019-08-08 20:01:39 · 542 阅读 · 0 评论 -
temple of the bone(dfs)
#include <iostream>#include <queue>using namespace std;#define N 7bool mark[N][N];char maze[N][N];int go[4][2] ={ -1,0, 1,0, 0,-1, 0,1,};int n, m, T, sx, sy, dx, dy, t;int f...原创 2019-02-11 21:50:06 · 193 阅读 · 0 评论 -
Oil Deposits(bfs)C++实现
#include <iostream>#include <queue>using namespace std;#define N 101int go[8][2] ={ -1,-1, -1,0, -1,1, 0,-1, 0,1, 1,-1, 1,0, 1,1,};struct E{ int x, y;};queue<E> Q...原创 2019-02-11 21:16:59 · 485 阅读 · 0 评论