Tag：adjacency matrix

Time：20211011
The concept of figure is almost introduced. You can digest it and continue to learn the following content. If there is no problem, we will continue to learn the next content. Of course, this is not the most troublesome place, because today we just introduce the storage structure of graphs. Sequential storage structure of graphs: […]

Time：20211010
In the last article, we learned the related storage structures of graphs, that is, adjacency matrix and adjacency table. They represent the most typical sequential storage and chain storage. Now that we have data structures, we will learn how to operate these data structures, that is, the algorithm. Whether it’s a graph or a tree, […]

Time：2021828
chart input 6 8 0 0 1 1 0 3 4 0 4 4 1 3 2 2 5 1 3 2 2 3 4 3 4 5 3 output 0 1 5 3 4 6 Adjacency matrix implementation #pragma warning (disable:4996) #include <cstdio> #include <vector> #include <algorithm> using namespace std; const int maxn = […]

Time：2021827
Pat 1003 emergency (25 points) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the […]

Time：2021821
Red and Black There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move only on black tiles. Write […]

Time：2021818
I don’t know how readers thought in the last issue. This issue of the article is followed by the last issue. The main content of this paper is: the C + + code implementation of graph (adjacency matrix method), mainly the specific implementation of each class Abstract base class of graph 1 // […]

Time：2021610
The concept of graph Related concepts Concept name definition adjacent vertex Two points are connected by an edge power The edge has a corresponding number network Weighted graph degree Degree = out degree + in degree route Vertex sequence path length In non weighted graph is the number of edges on the path, and in […]

Time：202164
adjacency matrix #include <stdio.h> #include <stdlib.h> #include <data.h> #define MAX_ VERTEX_ Num 20 // maximum number of vertices #Define vrtype int // relationship between vertices #Define infotype char // pointer variable to store arc or extra information #Define vertex type int // vertex data type typedef enum{DG,DN,UDG,UDN}GraphKind;// Four types of enumeration graphs Typedef struct // […]

Time：2021310
Suppose we want to create a class for graph. The adjacency matrix representation of this kind of storage graph. So our class structure looks like this. class Graph { int V; int adj[V][V]; }; int main() { } Even if we set V to static, there will be an error “array boundary is […]

Time：2021217
Depth first search of graphs 1. Push the first vertex into the stack; 2. As long as there are still vertices in the stack, the following operations are performed in the loop: (1) Access the vertex u at the top of the stack; (2) When moving from the currently accessed vertex u to the vertex […]

Time：202123
From today on, we begin to introduce the graph related algorithm diagram: what is “graph”? 1. Background As the beginning of graph, let’s look at a classical problem, which is considered to be the origin of graph theory. The problem is based on a reallife example: there are two small islands in the middle of […]

Time：202114
This example for you to share the C + + implementation diagram adjacent matrix code, for your reference, the specific content is as follows 1. Problems encountered: it is written in the textbook that the subclass graphmtx (I use grapmatrix) inherits the base class graph However, I use the protected member property of the parent […]