AlgoDocs

Graph

A collection of nodes (vertices) connected by edges

Introduction

A Graph is a non-linear data structure used to represent a set of objects (nodes or vertices) and their connections (edges). Graphs are widely used to model relationships in networks, such as social networks, transportation systems, web page links, and more.

Components of Graph

Vertices (Nodes):

  • These are the individual entities in the graph.

  • Represented as points or circles.

Edges (Links):

  • These are the connections between pairs of vertices.

  • Represented as lines connecting the vertices.

Weight:

  • Some graphs assign a value or weight to edges, representing a cost, distance, or strength of the connection.

Visualization of Graph

Types of Graph

Directed Graph

  • Each edge has a direction, going from one vertex to another.

Visualization of Directed Graph

Undirected Graph:

  • Edges have no direction; connections are mutual.

Visualization of Undirected Graph

Weighted Graph:

  • Edges have weights representing costs, distances, or other values.

Visualization of Weighted Graph

Unweighted Graph:

  • Edges are treated equally, with no weights assigned.

Visualization of Unweighted Graph

Cyclic Graph:

  • Contains at least one cycle (a path that starts and ends at the same vertex).

Visualization of Cyclic Graph

Acyclic Graph:

  • Does not contain any cycles.

Visualization of Acyclic Graph

How is this guide?