0% found this document useful (0 votes)
25 views

Lecture 01 Graphs

The document discusses graphs and their applications. It defines a graph as consisting of vertices and edges, where vertices can represent entities like cities and edges represent connections between them. Graphs can model real-world networks like transportation systems. The document also defines key graph terminology, describes directed and undirected graphs, and discusses variations of graphs like weighted and multigraphs.

Uploaded by

asif01cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Lecture 01 Graphs

The document discusses graphs and their applications. It defines a graph as consisting of vertices and edges, where vertices can represent entities like cities and edges represent connections between them. Graphs can model real-world networks like transportation systems. The document also defines key graph terminology, describes directed and undirected graphs, and discusses variations of graphs like weighted and multigraphs.

Uploaded by

asif01cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Graph

Dr. Md Masbaul Alam Polash


Associate Professor
Computer Science and Engineering
Jagannath University
Graph & BFS / Slide 2

Graphs
 Extremely useful tool in modeling problems
 Consist of:
 Vertices
Vertices can be
 Edges D considered “sites”
E
or locations.
C
A Edges represent
F connections.
B
Vertex
Edge
Graph & BFS / Slide 3

Application
Air flight system

• Each vertex represents a city


• Each edge represents a direct flight between two cities
• A query on direct flights = a query on whether an edge exists
• A query on how to get to a location = does a path exist from A to B
• We can even associate costs to edges (weighted graphs), then ask
“what is the cheapest path from A to B”
Graph & BFS / Slide 4

Definition
 A graph G=(V, E) consists a set of vertices, V, and a set of edges, E.
 Each edge is a pair of (v, w), where v, w belongs to V
 If the pair is unordered, the graph is undirected; otherwise it is directed

{a,b} {a,c}

{b,d} {c,d}

{b,e} {c,f}

{e,f}

An undirected graph
Graph & BFS / Slide 5

Terminology
1. If v1 and v2 are connected, they are said to be
adjacent vertices
 v1 and v2 are endpoints of the edge {v1, v2}

2. If an edge e is connected to v, then v is said to


be incident on e. Also, the edge e is said to be
incident on v.
If we are talking about directed graphs, where edges have direction. This means that
{v1,v2} ≠ {v2,v1} . Directed graphs are drawn with arrows (called arcs) between edges.
A B This means {A,B} only, not {B,A}
Graph & BFS / Slide 6

Graph Variations
 Variations:
 A connected graph has a path from every vertex
to every other
 In an undirected graph:
Edge (u,v) = edge (v,u)

No self-loops

 In a directed graph:
Edge (u,v) goes from vertex u to vertex v, notated uv
Graph & BFS / Slide 7

Graph Variations
 More variations:
 A weighted graph associates weights with
either the edges or the vertices
E.g., a road map: edges might be weighted w/ distance

 A multigraph allows multiple edges between


the same vertices
E.g., the call graph in a program (a function can get called

from multiple points in another function)


Thank You

You might also like