Associative Array Graph
Associative Array Graph
An associative array, also known as a map, dictionary, or hash table in various programming
languages, is a data structure that stores key-value pairs. It allows you to associate a unique
key with a specific value and retrieve, update, or delete the value using the key.
Definitions:
1. Map: An interface in Java that maps unique keys to
values.
2. Key: A unique identifier for a value in the map.
3. Value: The data associated with a key.
Functions:
Insertion: Add a new key-value pair or update an existing
key's value.
Deletion: Remove a key-value pair using the key.
Lookup: Retrieve the value associated with a specific
key.
Update: Change the value associated with a particular
key.
// Declare an associative array
Example in Java and in (dictionary/map)
ASSOCIATIVE_ARRAY myMap
PSUEDO CODE:
// Add key-value pairs to the associative
Here’s an example using array
myMap["Alice"] = 30
Hash Map, a commonly used myMap["Bob"] = 25
Functions:
Add Vertex: Insert a new vertex into the graph.
Add Edge: Insert a connection between two vertices.
Remove Vertex: Remove a vertex and its associated
edges from the graph.
Remove Edge: Remove a connection between two
vertices.
Traversal: Explore the graph using methods like Depth-
First Search (DFS) or Breadth-First Search (BFS).
Here's an example of a
simple directed &
undirected graph
implementation using an
adjacency list:
Explanation of the Example:
Add Edge: Adds an edge between two vertices, updating both lists
to maintain undirected connectivity.