Explore tens of thousands of sets crafted by our community.
Graph Data Structures
7
Flashcards
0/7
Adjacency Map
A map where each key is a vertex and each value is a map of neighboring vertices to the edge properties (such as weights). Best used for weighted graphs when we need constant-time access to the edge weights between neighbors or when the graph is sparse.
Adjacency Hash Table
A hash table where keys represent vertices and values are lists or sets of neighboring vertices. Best used when the graph structure may change frequently as it allows for fast addition and deletion of vertices and edges.
Adjacency List
A collection of lists or arrays used to represent graph connections. Each list corresponds to a vertex and contains the list of neighbors. Best used when the graph is sparse and you need to frequently iterate over the neighbors of a vertex.
Linked Edge List
A variation of the edge list where each edge is a node with pointers to the next edge, along with references to its endpoints. Best used for graphs that need to frequently add or remove edges and maintain other edges' references.
Incidence Matrix
A 2D boolean matrix with rows representing vertices and columns representing edges, indicating whether the vertex at row i is incident to the edge at column j. Best used for edge-centric operations or for graphs where both vertices and edges need to be efficiently queried.
Edge List
A list of edges, where each edge is represented as a tuple (vertex1, vertex2). Best used when the graph has a very small number of edges or we need to iterate over all edges regardless of their vertices.
Adjacency Matrix
A 2D array with dimensions VxV, where V is the number of vertices. The cell at [i][j] reflects the presence of an edge between vertex i and j. Best used when the graph is dense or when we need to check quickly whether there is an edge between two vertices.
© Hypatia.Tech. 2024 All rights reserved.