Data Structure & Algorithm in Java

⌘K
  1. Home
  2. Docs
  3. Data Structure & Alg...
  4. Graphs
  5. Introduction

Introduction

A graph is a collection of nodes (vertices) and edges that connect pairs of nodes.

• It is used to create a pairwise relationship between objects.

» Vertex:

A vertex (also called a node or a point) is a basic unit in a graph. It represents an object in the system that is being modeled.

» Edge:

An edge (also called a link or a line) is a connection between two vertices in a graph. It represents a relationship between the two objects that the vertices represent.

» Formally, a graph is denoted as a pair G(V, E).

Where V represents the finite set vertices and E represents the finite set edges.

• Therefore, we can say a graph includes non-empty set of vertices V and set of edges E.

Example
Suppose, a Graph G=(V,E),

where Vertices, V={a,b,c,d}
Edges, E={{a,b},{a,c},{b,c},{c,d}}

  • Social Networks
  • Routing and Networking
  • Transportation Systems
  • Database Management
  • Computer Networks
  • Game Development

Directed Graph:

A directed graph, or digraph, is a graph in which the edges have a direction. This means that each edge points from one vertex to another vertex.

image 163

Undirected Graph:

An undirected graph, on the other hand, is a graph in which the edges do not have a direction. This means that each edge connects two vertices, but it does not matter which vertex the edge is pointing from.

image 164
image 58
image 59
cyclic
image 61
image 60

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *