Home > Back-end >  Data results in questions about the figure, a great god help!
Data results in questions about the figure, a great god help!

Time:12-19

 # include 
#include
#include
using namespace std;
Typedef struct ENnode {
Int adjvex;
Int weight;
ENode * nextarc;
} ENode;
Typedef struct Vnode
{
Int vertex.
ENode * firstarc;
Int edge;
} VNode.
The class Graph
{
Public:
Virtual void CreateAdj (int v, int e, int weight)=0.
//virtual void FindEdge (int x)=0.//output X adjacency list
};
The class DirectedGraph: public Graph
{
Private:
Vertex VNode *;
Int v, e;
Public:
DirectedGraph (int a, int b)
{
Vertex=new VNode.
int j=0;
for (int i=0; i {
J=I + 1;
Vertex [I]. Vertex=j;
Vertex [I]. Edge=0;
Vertex [I] firstarc=new ENode;
Vertex [I] firstarc - & gt; Adjvex=0;
Vertex [I] firstarc - & gt; Nextarc=NULL;
Vertex [I] firstarc - & gt; Weight=0;
}
V=a;
E=b;
}
Void CreateAdj (int v1, int v2, int weight)
{
ENode * temp=new ENode;
Temp - & gt; Adjvex=v2;
Temp - & gt; Weight=weight;
Temp - & gt; Nextarc=NULL;
Temp - & gt; Nextarc=vertex - 1 [v] firstarc - & gt; Nextarc;
Vertex - 1 [v] firstarc - & gt; Nextarc=temp;
Vertex [v - 1]. Edge++;
}
Void DispAdj ()
{
int i;
ENode * temp;
For (I=0; i {
Temp=vertex [I] firstarc;
Printf (" % 3 d: ", I);
While (temp!=NULL)
{
Printf (" % 3 d [% d] - & gt;" , temp & gt; Adjvex, temp & gt; Weight);
Temp=temp - & gt; Nextarc;
}
}
}
};
Int main ()
{
DirectedGraph temp (3, 4);
Int v, e, w, I=0;
While (I & lt; 5)
{
Cin & gt;> V & gt;> E & gt;> w;
Temp. CreateAdj (v, e, w);
i++;
}
Temp. DispAdj ();
}

When I test input for 1 2 5 v e w (test data) will appear the following error
Seek help from a great god!!
  • Related