Download presentation
Presentation is loading. Please wait.
Published byEugene Flowers Modified over 6 years ago
1
Basic Concepts Graphs For more notes and topics visit:
eITnotes.com
2
Graphs – Basic Concepts
Basic definitions: vertices and edges More definitions: paths, simple paths, cycles, loops Connected and disconnected graphs Complete graphs Weighted graphs Graph representation Adjacency matrix Adjacency lists eITnotes.com
3
Basic Graph Definitions
A graph is a non-linear data structure that consists of a collection of nodes(or vertices) and a collection of edges(or arcs), with each edge joining one node to another. Formally, a graph G = (V,E) consists of two sets: V called set of all vertices or nodes. E called set of all edges or arcs. Vertices are represented by circles or points and edges as line segments or arcs connecting the vertices. eITnotes.com
4
Vertices and Edges Definition: A graph is a collection (nonempty set) of vertices and edges Vertices: can have names Edges: connect two vertices, can be labeled, can be directed Adjacent vertices: there is an edge between them eITnotes.com
5
Example Vertices: A,B,C,D Edges: AB, AC, BC, CD A C B D A B C D Graph1
eITnotes.com Two ways to draw the same graph
6
Directed and undirected graphs
B C D eITnotes.com These are two different graphs
7
More definitions : Path
A list of vertices in which successive vertices are connected by edges A B C B A C D A B C A B C A B C D B A B A C A B C D eITnotes.com
8
More definitions : Simple Path
No vertex is repeated. A B C D D C A D C B A B A B C A B C D eITnotes.com
9
More definitions : Cycle
A loop is a special case of cycle in which an edge begin and ends with the same vertex. A B C D A B C A B A C B C B A C eITnotes.com A graph without cycles is called acyclic graph.
10
Connected and Disconnected graphs
Connected graph: There is a path between each two vertices Disconnected graph : There are at least two vertices not connected by a path. Examples of disconnected graphs: A B C D eITnotes.com
11
Degree of vertex In an undirected graph, the degree of a vertex is the number of edges originating from it. In directed graph degree of vertex comes in two variations: a) Indegree b) Outdegree eITnotes.com
12
Complete graphs Graphs with all edges present – each vertex is connected to all other vertices A B C D E A complete graph eITnotes.com
13
Weighted graphs Weighted graphs – weights are assigned to each edge (e.g. road map) B 2 1 C A 2 4 3 D eITnotes.com
14
Graph Representation Adjacency matrix Adjacency lists eITnotes.com
15
Adjacency matrix – undirected graphs
Vertices: A,B,C,D Edges: AC, AB, AD, BD A B C D A B C D The matrix is symmetrical A B C D eITnotes.com
16
Adjacency matrix – directed graphs
Vertices: A,B,C,D Edges: AC, AB, BD, DA A B C D A B C D A B C D eITnotes.com
17
Adjacency lists – undirected graphs
Vertices: A,B,C,D Edges: AC, AB, AD, BD Heads lists A B C D B A D C A D A B A B C D eITnotes.com
18
Adjacency lists – directed graphs
Vertices: A,B,C,D Edges: AC, AB, BD, DA Heads lists A B C B D C = D A A B C D eITnotes.com
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.