Data structure Tutorials--definition and terminology of the 26th lesson diagram

Source: Internet
Author: User
Tags definition range

Teaching Purpose: To master the definition of graphs and the common terms

Teaching Emphasis: The common terminology of graphs

Teaching Difficulties: common terminology of graphs

Teaching Content:

I. Definition of graphs

A graph is a data structure that is a many-to-many relationship between data elements, plus an abstract data type consisting of a set of basic operations.

ADT graph{

A data Object V:V is a collection of data elements that have the same characteristics, called vertex sets.

Data relation R:

R={VR}

Vr={<v,w>|v,w (-V and P (v,w),<v,w> represent arcs from V to W, and predicate P (v,w) defines the meaning or information of the arc <v,w>}

Basic Operations P:

Creategraph (&G,V,VR);

Initial condition: V is the vertex set of the graph, and VR is the set of arcs in the graph.

Operation Result: construct graph G by definition of V and VR

Destroygraph (&G);

Initial condition: Figure G exists

Operation Result: Destroy Figure g

Locatevex (G,u);

Initial condition: Fig g exists, the vertex in U one G has the same characteristic

Operation Result: If there is a vertex u in G, then return the vertex to the position in the diagram; otherwise, other information will be returned.

Getvex (G,V);

Initial condition: The figure G exists, V is a vertex in G

Action Result: Returns the value of V.

Putvex (&g,v,value);

Initial condition: The figure G exists, V is a vertex in G

Operation Result: value of V Assignment

Firstadjvex (G,V);

Initial condition: The figure G exists, V is a vertex in G

Action Result: Returns the first contiguous vertex of V. If the vertex does not have an adjacent vertex in G, it returns "NULL"

Nextadjvex (G,V,W);

Initial conditions: The existence of Fig G, V is a vertex in G, W is the adjacent vertex of v.

Action Result: Returns the next contiguous vertex of V (relative to W). If W is the last contiguous point of V, return "null"

Insertvex (&G,V);

Initial condition: The existence of Fig G, V and vertex in the diagram have the same characteristics

Operation Result: Add a new vertex v in Fig g

Deletevex (&G,V);

Initial condition: The figure G exists, V is a vertex in G

Action Result: delete vertex v in G and its associated arc

INSERTACR (&G,V,W);

Initial conditions: Existence of fig G, V and W are two vertices in g

Operation Result: Add Arc <v,w> in G, if G is non direction, add symmetrical arc <w,v>

Deletearc (&G,V,W);

Initial conditions: Existence of fig G, V and W are two vertices in g

Operation Result: The arc <v,w> is removed in G, and if G is not, the symmetrical arc is also removed <w,v>

Dfstraverser (G,v,visit ());

Initial condition: The existence of Fig G, V is a vertex in G, visit is the application function of vertex

Operation Result: from Vertex v to depth first traverse graph G, and call function visit for each vertex. Once visit () fails, the operation fails.

Bfstraverse (G,v,visit ());

Initial condition: The existence of Fig G, V is a vertex in G, visit is the application function of vertex

Operation Result: from Vertex v breadth first traversal graph G, and call function visit for each vertex. Once visit () fails, the operation fails.

}adt Graph

Ii. Common terms for graphs

On the above figure are: G1= (V1,{A1})

Where: V1={v1,v2,v3,v4} A1={<v1,v2>,<v1,v3>,<v3,v4>,<v4,v1>}

If n is used to represent the number of vertices in the graph, the number of edges or arcs is represented by E:

For a n-1 graph, the range of values for E is 0 to n ()/2, and the non-direction graph with N (n-1)/2 edges is called a complete graph.

For a direction graph, E has a value range of 0 to N (n-1). A direction graph with N (n-1) arcs is called a forward-complete graph.

A graph with few edges or arcs is called a sparse graph, whereas a dense one.

V1 and v2 are mutually adjacent contacts
E1 attached to vertex v1 and v2
V1 and v2 Associated
V1 is 3 degrees.

For a direction graph, if there is a path between each pair of vertices, the graph is called a strongly connected graph.

Third, summary

Characteristics of graphs

The main difference between a direction graph and a non-direction graph

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.