Total WebSite Views Count

Graph Basic Time Complexity & Graph Representations & Basic Operation

Adjacency listAdjacency matrixIncidence matrix
Store graph
Add vertex
Add edge
Remove vertex
Remove edge
Query: are vertices x and y adjacent? 
RemarksSlow to remove vertices and edges, because it needs to find all vertices or edgesSlow to add or remove vertices, because matrix must be resized/copiedSlow to add or remove vertices and edges, because matrix must be resized/copied

Graph Representations

Different data structures for the representation of graphs are used in practice:
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.
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 Boolean matrix, in which the rows represent the vertices and columns represent the edges. The entries indicate whether the vertex at a row is incident to the edge at a column.

The basic operations provided by a graph data structure G usually include:
  • adjacent(Gxy): tests whether there is an edge from the vertices x to y;
  • neighbors(Gx): lists all vertices y such that there is an edge from the vertices x to y;
  • add_vertex(Gx): adds the vertex x, if it is not there;
  • remove_vertex(Gx): removes the vertex x, if it is there;
  • add_edge(Gxy): adds the edge from the vertices x to y, if it is not there;
  • remove_edge(Gxy): removes the edge from the vertices x to y, if it is there;
  • get_vertex_value(Gx): returns the value associated with the vertex x;
  • set_vertex_value(Gxv): sets the value associated with the vertex x to v.
Structures that associate values to the edges usually also provide:
  • get_edge_value(Gxy): returns the value associated with the edge (xy);
  • set_edge_value(Gxyv): sets the value associated with the edge (xy) to v.


A

AWS Services

AWS Services

Technology Selection & Evaluation Criteria

Technology Selection & Evaluation Criteria

Scale Cube - Scale In X Y Z Cube

Scale Cube - Scale In X Y Z Cube

Feature Post

AWS Services

About Me

About Me

Spring Cloud

Spring Cloud
Spring Cloud

Spring Cloud +mCloud Native + Big Data Archittect

Spring Cloud +mCloud Native + Big Data Archittect

ACID Transaction

ACID Transaction

Data Pipe Line Stack

Data Pipe Line Stack

Popular Posts