Data Structure - Graph Type

A graph can be defined as a set of vertices and edges that connect these vertices. A graph can be viewed as a cyclic tree, where the vertices (nodes) maintain any complex relationship between them, rather than a simple parent-child relationship.

1. Graph definition

GraphG can be defined as an ordered setG(V,E), whereV(G) represents the set of vertices, E(G) represents the set of edges used to connect these vertices.

PictureG(V,E)Yes5Two points(A,B,C,D,E)Japanese 6 pieces((A,B),(B,C),(C,E),(E,D), (D,B),(D,A))As below Showing pictures.

2. Directed and undirected graphs

Graphs can be directed or undirected. However, in an undirected graph, the edges are independent of their direction. An undirected graph is shown in the above image because its edges are not connected to any direction. If there is an edge between vertices A and B, then the vertex can be traversed from B to AAnd traverse from A to B.

In a directed graph, edges form ordered pairs. An edge represents a specific path from a vertex A to another vertexB. Node A is called the initial node, and node B is called the terminal node.

The directed graph is shown in the figure below.

3. Graph technology

3.1. Path

A path can be defined as a sequence of nodes to follow in order to get from an initial nodeU to some terminal nodeV.

3.2. Closed path

If the initial node and the terminal node are the same, the path is called a closed path. If V0 = VN, the path will be closed.

3.3. Simple path

If all the nodes of the graph are abnormal and abnormalV0 = VN, then such a pathP is called a closed simple path.

3.4. Cycle

A cycle can be defined as a path with no repeating edges or vertices except the first and last vertex.

3.5. Connected graph

A connected graph is a graph in which there are some paths between every two vertices in V. There are no isolated nodes in a connected graph. (u,v)

3.6. Complete graph

A complete graph is a graph in which every node is connected to all other nodes. The complete graph contains n(n-1/2 edges, where n is the number of nodes in the graph.

3.6. Weight graph

In a weight graph, each edge is assigned some data, such as length or weight. The weight of an edge e can be given as w(e), which must be a positive (+) value indicating the cost of crossing the edge.

3.7. Directed graph

A directed graph is a directed graph in which each edge of the graph is associated with a direction and can only be traversed in a specified direction.

3.8. Loops

Edges associated with similar endpoints may be called cycles.

3.9. Adjacent nodes

If two nodesu and v are connected by an edge e, then nodeu andv are called neighbors or adjacent nodes.

3.10. Degree of node

The degree of a node is the number of edges connected to the node. Nodes with degree0 are called isolated nodes.


 

Guess you like

Origin blog.csdn.net/unbelievevc/article/details/134822070