In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the characteristics of the database adjacency table". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
two。 Characteristics of adjacency table (undirected graph):
Sometimes the adjacency matrix is not a good choice:
Such as the above figure: the number of edges is relatively small, this structure is undoubtedly a great waste of storage space.
Adjacency table: arrays and linked lists are combined to store.
1.) vertices are stored in an one-digit array.
2.) all the adjacent points of each vertex Vi form a linear table. Because the number of adjacent points is uncertain, we choose a single linked list to store.
two。 Characteristics of adjacency tables (digraphs):
Take the vertices as the adjacency table established at the end of the arc, so that you can easily get the degree of each vertex.
Sometimes in order to determine the entry degree of a vertex or an arc with a vertex as the arc head, we can establish an inverse adjacency table of a directed graph:
3. The characteristics of the adjacency table (network):
For a network graph with weights, you can add another data field to the edge table node definition to store the weights:
Typedef char Vtype / / Vertex type typedef int Etype / / weight type # definde MAXV 100 alternate typedef struct edgeNode / / Edge table node {int adjvex; / / adjacent points store the corresponding subscript Etype weight;// edge weights struct edgeNode * next;} EdgeNode;typedef struct Vnode / / vertex table node {Vtype data; EdgeNode* firstEdge;} VNODE; / / typedef struct {VNODE adjlist [MAXV] Int numV;// current number of vertices int numE;// current number of sides} GraphAdjList; void CreateALGraph (GraphAdjList* G) {int iLecture jLING; EdgeNode* e = NULL; cout > G-> numE; for (iS0 + +) / / create vertex information {cin > > G-> adjlist [I] .data / / enter vertex information G-> adjlist [I] .firstEdge = NULL; / / the edge table node is empty} for (kappa next = j; e-> next = G-> adjlist [I] .firstEdge; / / similar to node- > next = list- > head; list- > head = node; G-> adjlisti] .firstEdge = e in the stack E = new EdgeNode; e-> adjvex = I; e-> next = G-> adjlist [j] .firstEdge; G-> adjlist [j] .firstEdge = e;}}
For an undirected graph, an edge corresponds to two vertices, so I and j are inserted in a loop for n vertices and e edges.
This is the end of the content of "what are the characteristics of the database adjacency table". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.