Among the directed graph, compute the number of l on line i, can get the vertex is outdegree. Compute the number of l on row i, can get the vertex i's indegree As for the undirected graph, Compute the number of l on row i, can get the vertex is degree
◼ Among the directed graph, compute the number of 1 on line i, can get the vertex i’s outdegree. Compute the number of 1 on row i, can get the vertex i’s indegree. ◼ As for the undirected graph, Compute the number of 1 on row i, can get the vertex i’s degree
Adjacency Matrix in the network w(i,j),ifi≠jand<i,j>∈Eor(,j)∈E Aedge证={∞ ifi≠jand<i,j>函Eor(ij)E ifi==j 8 (2 3 6 01∞4 o092 39 52 Aeage 3508 60 0 1 (
1 8 6 3 9 2 5 4 2 0 3 1 = 6 0 3 5 0 8 0 9 2 0 1 4 A.edge Adjacency Matrix in the network == = i j i j i , j i , j i j i j i , j i , j i j i f i f and o r i f and o r , , ( ) ( , ), ( ) [ ][ ] 0 E E W E E A.edge
using Adjacency Matrix to define the graph # define maxvalue Int Max//在< <limits. h>中 const int NumEdges =50 //edges' number const int NumVertices= 10://vertex's number typedef char Vertex Data; //vertex's data type typedef int Edge Data; // Edge's weight typedef struct t Vertex Data vexList[NumVertices]://vertex table Edge Data Edge [Num][Num Vertices]: //adjacency can be treat as the edge relation Int n, e://the number of the vertex and edge 1 MTGraph;
#define MaxValue Int_Max //在<limits.h>中 const int NumEdges = 50; //edges’ number const int NumVertices = 10; // vertex’s number typedef char VertexData; // vertex’s data type typedef int EdgeData; // Edge’s weight typedef struct { VertexData vexList[NumVertices]; //vertex table EdgeData Edge[NumVertices][NumVertices]; //adjacency can be treat as the edge’ relation int n, e; //the number of the vertex and edge } MTGraph; using Adjacency Matrix to define the graph
Adjacency List Adjacency List: A list type of storage structure The structure of arc adjvex nextarc info adivex; //the vertex which arc point to nextarc / point to the next arc pointer info:// the relative information of arc 顶点的结点结构 data firstarc data; //the vertex'information firstarc; //point to the first arc which associate the vertex
Adjacency List ▪ Adjacency List: A list type of storage structure。 ▪ The structure of arc adjvex; // the vertex which arc point to nextarc;// point to the next arc ’pointer info; // the relative information of arc adjvex nextarc info ▪顶点的结点结构 data firstarc data; // the vertex’ information firstarc; //point to the first arc which associate the vertex
a The adjacency list of undirected graph data adj dest link dest link A 0A 10 3∧ B 1 B 彐[2 2C 1∧ 3D 0 These edges come from the same vertex are in the same list. Each list node is delegated a certain edge(edge node), the node contain another vertex suflix--dest and pointer--linko
▪The adjacency list of undirected graph These edges come from the same vertex are in the same list. Each list node is delegated a certain edge(edge node), the node contain another vertex’ suffix--dest and pointer--link。 A B C D data adj A B C D 0 1 2 3 dest link dest link 1 3 0 2 1 0