Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE) PDF Download

Introduction

A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links that connect the vertices are called edges.
Formally, a graph is a pair of sets (V, E), where V is the set of vertices and E is the set of edges, connecting the pairs of vertices. Take a look at the following graph −
Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE)

In the above graph,
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}

Graph Data Structure

Mathematical graphs can be represented in data structure. We can represent a graph using an array of vertices and a two-dimensional array of edges. Before we proceed further, let's familiarize ourselves with some important terms −

  • Vertex: Each node of the graph is represented as a vertex. In the following example, the labeled circle represents vertices. Thus, A to G are vertices. We can represent them using an array as shown in the following image. Here A can be identified by index 0. B can be identified using index 1 and so on.
  • Edge: Edge represents a path between two vertices or a line between two vertices. In the following example, the lines from A to B, B to C, and so on represents edges. We can use a two-dimensional array to represent an array as shown in the following image. Here AB can be represented as 1 at row 0, column 1, BC as 1 at row 1, column 2 and so on, keeping other combinations as 0.
  • Adjacency: Two node or vertices are adjacent if they are connected to each other through an edge. In the following example, B is adjacent to A, C is adjacent to B, and so on.
  • Path: Path represents a sequence of edges between the two vertices. In the following example, ABCD represents a path from A to D.

Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE)

Basic Operations

Following are basic primary operations of a Graph:

  • Add Vertex: Adds a vertex to the graph.
  • Add Edge: Adds an edge between the two vertices of the graph.
  • Display Vertex: Displays a vertex of the graph.

The document Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Programming and Data Structures.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
Are you preparing for Computer Science Engineering (CSE) Exam? Then you should check out the best video lectures, notes, free mock test series, crash course and much more provided by EduRev. You also get your detailed analysis and report cards along with 24x7 doubt solving for you to excel in Computer Science Engineering (CSE) exam. So join EduRev now and revolutionise the way you learn!
Sign up for Free Download App for Free
120 docs|30 tests

Up next

120 docs|30 tests
Download as PDF

Up next

Explore Courses for Computer Science Engineering (CSE) exam
Related Searches

Exam

,

MCQs

,

Semester Notes

,

pdf

,

mock tests for examination

,

Sample Paper

,

Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE)

,

Free

,

study material

,

Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE)

,

Objective type Questions

,

practice quizzes

,

Viva Questions

,

ppt

,

Summary

,

Previous Year Questions with Solutions

,

video lectures

,

shortcuts and tricks

,

Extra Questions

,

Basic Terminology & Operations | Programming and Data Structures - Computer Science Engineering (CSE)

,

past year papers

,

Important questions

;