# Data Structures: Weighted Undirected Graphs

Learning >
Weighted Undirected Graph Data Structure

## What is a Weighted Undirected Graph?

A **weighted undirected graph** is a data structure that extends Weighted Graph by assuming all edges to be bidirectional.
As an **undirected graph**, once an edge between vertex A and B is set, it meaks B will be connected to A as well.

## How can it be implemented?

This data structure merely completes Weighted Graph specification and defines no further operations.
As a complete implementation, it must take a decision how to store vertexes inside. Options are equivalent to those used in storing EDGES:

- Dynamic Array implementing List of VERTEX: very fast to iterate, very slow to search a value/vertex into. To be used if value inside vertex is not unique! If used, EDGES must use same storage option.
- Hash Table implementing Set of VERTEX: quite fast to iterate, very fast to search a value/vertex into. To be used if value inside vertex is unique! If used, EDGES must use Hash Table implementing Associative Array where key is VERTEX and value is WEIGHT storage option.

If Dynamic Array implementing List solution is chosen, two more operations
can be generalized for **weighted undirected graph**, both executed in constant O(1) time:

**Operation** |
**Arguments** |
**Returns** |
**Description** |

contains |
DATA |
boolean |
Checks if graph contains a vertex whose value equals that of input. |

search |
DATA |
VERTEX |
Searches graph for a vertex whose value equals that of input. |