Skip to content

Graph

Introduction to Graph

A graph is a data structure that stores connected data.

Essentially, a graph, denoted as G or g, comprises a collection of vertices (V) and edges (E) that interlink these vertices. Within a graph, both vertices and edges play pivotal roles, with vertices symbolizing data points and edges indicating the connections among them. A vertex is typically represented by a circle with an identifying label, while an edge is signified by a line that joins two vertices.

Vertices: These are the junctions where edges meet, encapsulating the data. They are also referred to as nodes and are marked by a circular shape with a label. The foundation of any graph is at least one vertex, such as a house or a bus stop.

Edges: Represented by lines that link two vertices, edges signify the relationships or connections between them. For instance, an edge could symbolize a route from your home to a bus stop.

Weight: This is an attribute assigned to an edge, indicating a quantitative measure of the connection, such as the distance between two cities, which in this case would be 100 kilometers.

Path: A path outlines a sequence of steps or connections taken to reach a destination from an origin point.

Short Video Lecture

(Video here)

VisualCodeChat Tutoring

Interact and Learn with VisualCodeChat!

After-class Exercises

(Exercises here)