Big talk data structure 18: adjacency matrix of the storage structure of graphs

Source: Internet
Author: User
Tags arrays

1. The characteristics of adjacency matrix (non-direction graph):

The adjacency matrix of graphs is stored by using two arrays to represent graphs:

1.) A one-dimensional array stores vertex information in a stored graph.

2.) A two-dimensional array (called an adjacency matrix) that stores information about an edge or arc in a graph.

In the figure above we set two arrays:

Vertex array: vertex[4] = {V0,v1,v2,v3}

Edge array: arc[4][4] is a symmetric matrix (0 means that there is no edge between vertices, 1 indicates the existence of edges between vertices)

2. The characteristics of adjacency matrix (forward graph):

The side of the non-direction graph constitutes a symmetric matrix, seemingly wasting half of the space, that if there is to the diagram storage, will not use the resources well?

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Vertex array Vertex[4] = {V0,v1,v2,v3}

Arc Array Arc[4][4] is also a matrix, but because it is a graph, the matrix is asymmetric.

such as: V1 to V0 arc, so arc[1][0] = 1, and V0 to V1 no arc, so arc[0][1] = 0

3. Characteristics of adjacency matrix (NET):

A map with a right on each side is called a net. The normal weight value indicates the distance between two points.

Here ∞ represents a value that is allowed by a computer greater than the weights on all sides.

Author: csdn Blog zdp072

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.