e01.org

Graph (abstract data type)

with three vertices (blue circles) and three edges (black arrows). In computer science, a graph is an abstract data type that is meant to implement the undirected graph and directed graph concepts from the field of graph theory within mathematics. A graph data structure consists of a finite (and possibly mutable) set of vertices (also called nodes or points), together with a set of unordered pairs of these vertices for an undirected graph or a set of ordered pairs for a directed graph. These pairs are known as edges (also called links or lines), and for a directed graph are also known as edges but also sometimes arrows or arcs. The vertices may be part of the graph structure, or may be... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

with three vertices (blue circles) and three edges (black arrows). In computer science, a graph is an abstract data type that is meant to implement the undirected graph and directed graph concepts from the field of graph theory within mathematics. A graph data structure consists of a finite (and possibly mutable) set of vertices (also called nodes or points), together with a set of unordered pairs of these vertices for an undirected graph or a set of ordered pairs for a directed graph. These pairs are known as edges (also called links or lines), and for a directed graph are also known as edges but also sometimes arrows or arcs. The vertices may be part of the graph structure, or may be external entities represented by integer indices or references. A graph data structure may also associate to each edge some edge value, such as a symbolic label or a numeric attribute (cost, capacity, length, etc.). ==Operations== The basic operations provided by a graph data structure G usually include: : tests whether there is an edge from the vertex x to the vertex y; : lists all vertices y such that there is an edge from the vertex x to the vertex y; : adds the vertex x, if it is not there; : removes the vertex x, if it is there; : adds the edge z from the vertex x to the vertex y, if it is not there; : removes the edge from the vertex x to the vertex y, if it is there; : returns the value associated with the vertex x; : sets the value associated with the vertex x to v. Structures that associate values to the edges usually also provide: : returns the value associated with the edge (x, y); : sets the value associated with the edge (x, y) to v. ==Common data structures for graph representation== Adjacency list Vertices are stored as records or objects, and every vertex stores a list of adjacent vertices. This data structure allows the storage of additional data on the vertices. Additional data can be stored if edges are also stored as objects, in which case each vertex stores its incident edges and each edge stores its incident vertices. Adjacency matrix A two-dimensional matrix, in which the rows represent source vertices and columns represent destination vertices. Data on edges and vertices must be stored externally. Only the cost for one edge can be stored between each pair of vertices. Incidence matrix A two-dimensional matrix, in which the rows represent the vertices and columns represent the edges. The entries indicate the incidence relation between the vertex at a row and edge at a column. The following table gives the time complexity cost of performing various operations on graphs, for each of these representations, with |V| the number of vertices and |E| the number of edges. In the matrix representations, the entries encode the cost of following an edge. The cost of edges that are not present are assumed to be ∞. Adjacency lists are generally preferred for the representation of sparse graphs, while an adjacency matrix is preferred if the graph is dense; that is, the number of edges |E| is close to the number of vertices squared, |V|^2 , or if one must be able to quickly look up if there is an edge connecting two vertices. 2D partitioning: Every processor gets a submatrix of the adjacency matrix. Assume the processors are aligned in a rectangle p = p_r \times p_c , where p_r and p_c are the amount of processing elements in each row and column, respectively. Then each processor gets a submatrix of the adjacency matrix of dimension (n/p_r)\times(n/p_c) . This can be visualized as a checkerboard pattern in a matrix. Therefore, each processing unit can only have outgoing edges to PEs in the same row and column. This bounds the amount of communication partners for each PE to p_r + p_c - 1 out of p = p_r \times p_c possible ones. ==Compressed representations== Graphs with trillions of edges occur in machine learning, social network analysis, and other areas. Compressed graph representations have been developed to reduce I/O and memory requirements. General techniques such as Huffman coding are applicable, but the adjacency list or adjacency matrix can be processed in specific ways to increase efficiency. ==See also== Graph traversal for more information on graph walking strategies Graph database for graph (data structure) persistency Graph rewriting for rule based transformations of graphs (graph data structures) Graph drawing software for software, systems, and providers of systems for drawing graphs Graph neural network for machine learning on graphs with deep neural networks. ==References== ==External links== Boost Graph Library: a powerful C++ graph library s.a. Boost (C++ libraries) Networkx: a Python graph library GraphMatcher a java program to align directed/undirected graphs. GraphBLAS A specification for a library interface for operations on graphs, with a particular focus on sparse graphs.

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Graph (abstract data type)". 1780452931. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1357528269

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·