[SOLVED] data structure graph

$25

File Name: data_structure_graph_.zip
File Size: 197.82 KB

5/5 - (1 vote)

()

1 2 3 4 5
10 6 5
VC++6.0 VC2010
1
2*;( 70%)
3
1.; 2.; 3.; 4.;

(C++) DATA STRUCTURE WITH C++ William Ford,William Topp
()

: : : 2
// ArcNode *firstedge;
T vertex;

:
:
1
2:
:
1. : (1); (2); (3); (4); (5)
2.
*3. G G u v
l
:
1.
struct ArcNode // {
int adjvex; //
ArcNode *next; };
template struct VertexNode {
};
const int MaxSize=10; template class ALGraph
{
//
public:
ALGraph(T a[ ], int n, int e); // n e ~ALGraph; //
T GetVex(int i); // i
void PutVex(int i, T value); // i value
void InsertVex(int i, T value); // i value

void DeleteVex(int i); void InsertArc(int i, int j); void DeleteArc(int i, int j); void DFSTraverse(int v); void BFSTraverse(int v);
private:
VertexNode adjlist[MaxSize]; int vertexNum, arcNum;
};
// i // i j // i j
// //
// //
template ALGraph::ALGraph(T a[ ], int n, int e)
{
vertexNum=n; arcNum=e; for (i=0; i >i>>j; //
s=new ArcNode; s->adjvex=j; s->next=adjlist[i].firstedge; adjlist[i].firstedge=s;
} }
template
void ALGraph::DFSTraverse(int v) {
// s
// s i
cout< adjvex;
if (visited[j]==0) DFSTraverse(j); p=p->next;
} }
template
void ALGraph::BFSTraverse(int v) {
front=rear=-1; //,
cout< adjvex;
visited[v]=1; Q[++rear]=v;
// p
//

if (visited[j]==0) {
cout< next; }
} }
2.
const int MaxSize=10; template class MGraph
{
public:
MGraph(T a[ ], int n, int e );
~MGraph( ) { } //
T GetVex(int i); // i
void PutVex(int i, T value); void InsertVex(int i, T value); void DeleteVex(int i);
void InsertArc(int i, int j); void DeleteArc(int i, int j); void DFSTraverse(int v); void BFSTraverse(int v);
private:
T vertex[MaxSize];
int arc[MaxSize][MaxSize]; int vertexNum, arcNum;
};
template
// i value // i value
// i // i j
// i j //
//
// // //
MGraph::MGraph(T a[ ], int n, int e) {
vertexNum=n; arcNum=e; for (i=0; i >i>>j; arc[i][j]=1; arc[j][i]=1;
// //
top= -1; count=0;
for (i=0; i adjvex;
adjlist[k].in;
if (adjlist[k].in==0) p=p->next;
} }
// 1 0 S[++top]=k;
if (count

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] data structure graph
$25