-
-
Walker_Yin
2020-02-06
4. NODE_CPP
-
截图
0赞 · 0采集
-
-
Walker_Yin
2020-02-06
3. NODE_H
-
截图
0赞 · 0采集
-
-
Walker_Yin
2020-02-06
2. CMAP_H
-
截图
0赞 · 0采集
-
-
Walker_Yin
2020-02-06
1. CMAP_H
-
截图
0赞 · 0采集
-
-
qq_楠_16
2018-03-13
- memset的用法
-
截图
0赞 · 0采集
-
-
慕斯0014741
2018-03-04
- 邻接矩阵的初始化
-
截图
0赞 · 0采集
-
-
慕妹2098627
2017-08-24
- 从六分五十秒开始看
-
截图
1赞 · 0采集
-
-
慕妹2098627
2017-08-24
- map本身是个标准库的名称 所以这里在前面加个C
-
截图
0赞 · 0采集
-
-
慕粉13788931120
2017-07-30
- 函数memset(void *_Dst, int _Val, size_t _Size)作用:
将已开辟内存空间_Dst的首_Size个字节的值设为值_Val,常用来初始化内存空间
-
0赞 · 0采集
-
-
charles_M
2017-04-24
- 图的基本函数
-
截图
0赞 · 0采集
-
-
精慕门4947531
2016-11-09
- /**************************************************************/
DMap::DMap(int capacity)
{
m_iCapacity=capacity;
m_iNodeCount=0;
m_pNodeArray=new Node[m_iCapacity];
m_pMatrix=new int [m_iCapacity*m_iCapacity];
//memset(m_pMatrix,0,m_iCapacity*m_iCapacity*sizeof(int));
for(int i=0;i<m_iCapacity*m_iCapacity*sizeof(int);i++)
{
m_pMatrix[i]=0;
}
}
DMap::~DMap(void)
{
delete []m_pNodeArray;
delete []m_pMatrix;
}
bool DMap::AddNode(Node* pNode)
{
if(pNode==NULL)
{
return false;
}
m_pNodeArray[m_iNodeCount]->m_cData=pNode->m_cData;
m_iNodeCount++;
return true;
}
void DMap::ResetNode()
{
for(int i=0;i<m_iNodeCount;i++)
{
m_pNodeArray[i].m_bVisited=false;
}
}
-
2赞 · 4采集
-
-
精慕门4947531
2016-11-09
- #ifndef DMAP_H
#define DMAP_H
#include <vector>
#include "Node.h"
using namespace std;
class DMap
{
public:
DMap(int capacity);
~DMap(void);
bool AddNode(Node* pNode);//向图中增加结点(顶点)
void ResetNode(); //重置顶点
bool SetValuetoMatricForDGraph(int row,int col,int val=1);//有向图设置
bool SetValuetoMatricForUGraph(int row,int col,int val=1);//无向图设置
void printMatrix();//打印邻接矩阵
void depthFirstTravers(int nodeindex);//深度优先遍历
void breadFirstTravers(int nodeindex);//广度优先遍历
private:
bool getValueFromMatrix(int row,int col, int &val);//从矩阵获取权值
void breadFirstrTraversImpl(vector <int> prevect);//广度优先遍历实现
private:
int m_iCapacity; //图中顶点数容量
int m_iNodeCount; //已添加顶点个数
Node* m_pNodeArray; //存放顶点数组
int* m_pMatrix; //存放邻接矩阵
};
#endif
-
2赞 · 3采集
-
-
风起了_
2016-10-22
- menset函数的功能就是进行内存的设定,不仅要计算数量的大小,还要计算每一个所占的内存的大小
memset(m_pMatrix, 0 , m_iCapacity * m_iCapacity * sizeof(int))
-
0赞 · 0采集