Adjacency list

Stefi Yu
Stefi YuBlogger en WordPress
GRAPHS
Adjacency Lists
Reporters: Group 10
Graph Jargon:
 Vertex
(also called a node) is a fundamental
part of a graph.
 Edge
(also called an arc) is another
fundamental part of a graph. It connects
two vertices to show that there is a
relationship between them.
Definition of Terms
 Weight
Edges may be weighted to show that
there is a cost to go from one vertex to
another.
 Path
a sequence of vertices such that any
two consecutive vertices are connected
by an edge.
Definition Of Terms (Con’t.)
Graph Illustration
Path from V3 to V1?
ADJACENCY LIST
Adjacency List
 A type of graph representation wherein
each vertex holds a list of every other
vertex adjacent to it.
 In an adjacency list implementation, we
keep a master list of all the vertices in the
Graph object and then each vertex
object in the graph maintains a list of the
other vertices that it is connected to.
Adjacency List
Adjacency List Illustration
Example of an Undirected Graph
Adjacency List Illustration
Node class:
Adjacency List Methods
int Node Node
Node data members:
• Reference to other nodes in the graph
• Reference to the linked list of its adjacent nodes
• Actual value of the node
 Graph()
creates a new, empty graph.
 Transformers:
 addNode()
adds an instance of Vertex to the graph.
 addEdge(Node1, Node2)
adds a new, directed edge to the graph that
connects two vertices.
 deleteNode(Node)
removes a node and any edges between this node
and other nodes.
 deleteEdge(Node1, Node2)
delete the edge between two given nodes: Node1
& Node 2.
Adjacency List Methods
 Observers:
 getVertices()
returns the list of all vertices in the graph.
 isEmpty()
determines whether the graph is empty.
 isLink(Node1, Node2)
returns true if edge(Node1, Node2) is present in the
graph, false otherwise.
Bonus method/s:
findPath(Node1, Node2)
//pre: Node1 and Node2 are existing in the graph
//post: returns the list of nodes on a path from Node1 to
Node2.
Adjacency List Methods
Pros and Cons of ADT:
 Advantages:
 Easy to retrieve all the adjacent nodes of a given
node(just traverse the list associated with the node)
 Easy to check whether a node has edges starting
from it
 Less memory space is needed.
 Limitation:
 More complex operation for checking whether there
is an edge between two given nodes.
Pros and Cons of ADT
Graph Traversal Algorithms
Depth First Search
 Puts unvisited nodes in a STACK.
Breadth First Search
 Puts unvisited nodes in a QUEUE.
Traversal Algorithms
Applications of ADT:
 The applications for graphs are many and
varied. They can be used to analyze
electrical circuits, develop project
schedules, find shortest routes, analyze
social relationships, and construct models
for the analysis and solution of many other
problems.
Applications of ADT
Applications of ADT Con’t
1 de 15

Recomendados

Graph Basic In Data structure por
Graph Basic In Data structureGraph Basic In Data structure
Graph Basic In Data structureIkhlas Rahman
2.1K vistas12 diapositivas
Graphs in Data Structure por
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structurehafsa komal
2.2K vistas22 diapositivas
Graphs In Data Structure por
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
45.6K vistas32 diapositivas
Graphs in data structure por
Graphs in data structureGraphs in data structure
Graphs in data structurehamza javed
1.8K vistas32 diapositivas
Graph data structure and algorithms por
Graph data structure and algorithmsGraph data structure and algorithms
Graph data structure and algorithmsAnandhasilambarasan D
2.2K vistas10 diapositivas
Graph theory in network system por
Graph theory in network systemGraph theory in network system
Graph theory in network systemManikanta satyala
13.3K vistas52 diapositivas

Más contenido relacionado

La actualidad más candente

Data structure - Graph por
Data structure - GraphData structure - Graph
Data structure - GraphMadhu Bala
6.3K vistas28 diapositivas
Graph Data Structure por
Graph Data StructureGraph Data Structure
Graph Data StructureKeno benti
606 vistas41 diapositivas
Graph theory and its applications por
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applicationsManikanta satyala
34.1K vistas57 diapositivas
2.5 graph dfs por
2.5 graph dfs2.5 graph dfs
2.5 graph dfsKrish_ver2
2.4K vistas16 diapositivas
Tree traversal techniques por
Tree traversal techniquesTree traversal techniques
Tree traversal techniquesSyed Zaid Irshad
3.1K vistas34 diapositivas
Graph traversal-BFS & DFS por
Graph traversal-BFS & DFSGraph traversal-BFS & DFS
Graph traversal-BFS & DFSRajandeep Gill
1.2K vistas35 diapositivas

La actualidad más candente(20)

Data structure - Graph por Madhu Bala
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala6.3K vistas
Graph Data Structure por Keno benti
Graph Data StructureGraph Data Structure
Graph Data Structure
Keno benti606 vistas
Graph theory and its applications por Manikanta satyala
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
Manikanta satyala34.1K vistas
2.5 graph dfs por Krish_ver2
2.5 graph dfs2.5 graph dfs
2.5 graph dfs
Krish_ver22.4K vistas
Graph traversal-BFS & DFS por Rajandeep Gill
Graph traversal-BFS & DFSGraph traversal-BFS & DFS
Graph traversal-BFS & DFS
Rajandeep Gill1.2K vistas
Graph Traversal Algorithm por jyothimonc
Graph Traversal AlgorithmGraph Traversal Algorithm
Graph Traversal Algorithm
jyothimonc7.3K vistas
Dijkstra’S Algorithm por ami_01
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
ami_0141.1K vistas
Graph Theory: Connectivity & Isomorphism por Ashikur Rahman
Graph Theory: Connectivity & Isomorphism Graph Theory: Connectivity & Isomorphism
Graph Theory: Connectivity & Isomorphism
Ashikur Rahman418 vistas
CS6702 graph theory and applications notes pdf book por appasami
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf book
appasami58.9K vistas
Graph representation por Tech_MX
Graph representationGraph representation
Graph representation
Tech_MX37.2K vistas
Trees data structure por Sumit Gupta
Trees data structureTrees data structure
Trees data structure
Sumit Gupta19.4K vistas
Presentation on Breadth First Search (BFS) por Shuvongkor Barman
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman17.8K vistas
Euler paths and circuits por 03446940736
Euler paths and circuitsEuler paths and circuits
Euler paths and circuits
034469407361.7K vistas
Breadth First Search & Depth First Search por Kevin Jadiya
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya8.2K vistas

Destacado

Loom & Functional Graphs in Clojure @ LambdaConf 2015 por
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Aysylu Greenberg
3.1K vistas71 diapositivas
Data Structures - Lecture 7 [Linked List] por
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Muhammad Hammad Waseem
6K vistas36 diapositivas
3 d printer project por
3 d printer project3 d printer project
3 d printer projectshiraz-shoupassi
1.3K vistas41 diapositivas
Graph data structure por
Graph  data structureGraph  data structure
Graph data structureFâhém Ähmêd
1.8K vistas18 diapositivas
Graphs por
GraphsGraphs
GraphsMohd Arif
5.6K vistas91 diapositivas
Data structure computer graphs por
Data structure computer graphsData structure computer graphs
Data structure computer graphsKumar
4.4K vistas22 diapositivas

Destacado(16)

Loom & Functional Graphs in Clojure @ LambdaConf 2015 por Aysylu Greenberg
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Aysylu Greenberg3.1K vistas
Graphs por Mohd Arif
GraphsGraphs
Graphs
Mohd Arif5.6K vistas
Data structure computer graphs por Kumar
Data structure computer graphsData structure computer graphs
Data structure computer graphs
Kumar 4.4K vistas
Graph data structure por Tech_MX
Graph data structureGraph data structure
Graph data structure
Tech_MX14.1K vistas
Depth first search and breadth first searching por Kawsar Hamid Sumon
Depth first search and breadth first searchingDepth first search and breadth first searching
Depth first search and breadth first searching
Kawsar Hamid Sumon8.5K vistas
Introduction to graph class 8 por Monika Rana
Introduction to graph class 8Introduction to graph class 8
Introduction to graph class 8
Monika Rana15.3K vistas
DATA STRUCTURES por bca2010
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca201096.8K vistas

Similar a Adjacency list

Lecture 5b graphs and hashing por
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
1.2K vistas56 diapositivas
Graph in data structure por
Graph in data structureGraph in data structure
Graph in data structurePooja Bhojwani
196 vistas28 diapositivas
logic.pptx por
logic.pptxlogic.pptx
logic.pptxKENNEDY GITHAIGA
4 vistas58 diapositivas
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx por
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxBRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxCHIRANTANMONDAL2
63 vistas11 diapositivas
Talk on Graph Theory - I por
Talk on Graph Theory - ITalk on Graph Theory - I
Talk on Graph Theory - IAnirudh Raja
4.2K vistas33 diapositivas
DATA STRUCTURES.pptx por
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptxKENNEDY GITHAIGA
8 vistas59 diapositivas

Similar a Adjacency list(20)

Lecture 5b graphs and hashing por Victor Palmar
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
Victor Palmar1.2K vistas
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx por CHIRANTANMONDAL2
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxBRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
CHIRANTANMONDAL263 vistas
Talk on Graph Theory - I por Anirudh Raja
Talk on Graph Theory - ITalk on Graph Theory - I
Talk on Graph Theory - I
Anirudh Raja4.2K vistas
data structures and algorithms Unit 2 por infanciaj
data structures and algorithms Unit 2data structures and algorithms Unit 2
data structures and algorithms Unit 2
infanciaj65 vistas
Graph theory concepts complex networks presents-rouhollah nabati por nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
nabati2.8K vistas

Último

Understanding GenAI/LLM and What is Google Offering - Felix Goh por
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix GohNUS-ISS
41 vistas33 diapositivas
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors por
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensorssugiuralab
15 vistas15 diapositivas
Report 2030 Digital Decade por
Report 2030 Digital DecadeReport 2030 Digital Decade
Report 2030 Digital DecadeMassimo Talia
14 vistas41 diapositivas
handbook for web 3 adoption.pdf por
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
19 vistas16 diapositivas
Uni Systems for Power Platform.pptx por
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
50 vistas21 diapositivas
The Importance of Cybersecurity for Digital Transformation por
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital TransformationNUS-ISS
27 vistas26 diapositivas

Último(20)

Understanding GenAI/LLM and What is Google Offering - Felix Goh por NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS41 vistas
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors por sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab15 vistas
Report 2030 Digital Decade por Massimo Talia
Report 2030 Digital DecadeReport 2030 Digital Decade
Report 2030 Digital Decade
Massimo Talia14 vistas
handbook for web 3 adoption.pdf por Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 vistas
The Importance of Cybersecurity for Digital Transformation por NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS27 vistas
DALI Basics Course 2023 por Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg14 vistas
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV por Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk88 vistas
The details of description: Techniques, tips, and tangents on alternative tex... por BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 vistas
AI: mind, matter, meaning, metaphors, being, becoming, life values por Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman27 vistas
Data-centric AI and the convergence of data and model engineering: opportunit... por Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 vistas
Business Analyst Series 2023 - Week 3 Session 5 por DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10209 vistas
Voice Logger - Telephony Integration Solution at Aegis por Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 vistas
Special_edition_innovator_2023.pdf por WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2216 vistas
Future of Learning - Khoong Chan Meng por NUS-ISS
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan Meng
NUS-ISS33 vistas
Spesifikasi Lengkap ASUS Vivobook Go 14 por Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 vistas
RADIUS-Omnichannel Interaction System por RADIUS
RADIUS-Omnichannel Interaction SystemRADIUS-Omnichannel Interaction System
RADIUS-Omnichannel Interaction System
RADIUS15 vistas

Adjacency list

  • 2. Graph Jargon:  Vertex (also called a node) is a fundamental part of a graph.  Edge (also called an arc) is another fundamental part of a graph. It connects two vertices to show that there is a relationship between them. Definition of Terms
  • 3.  Weight Edges may be weighted to show that there is a cost to go from one vertex to another.  Path a sequence of vertices such that any two consecutive vertices are connected by an edge. Definition Of Terms (Con’t.)
  • 6. Adjacency List  A type of graph representation wherein each vertex holds a list of every other vertex adjacent to it.  In an adjacency list implementation, we keep a master list of all the vertices in the Graph object and then each vertex object in the graph maintains a list of the other vertices that it is connected to. Adjacency List
  • 7. Adjacency List Illustration Example of an Undirected Graph
  • 9. Node class: Adjacency List Methods int Node Node Node data members: • Reference to other nodes in the graph • Reference to the linked list of its adjacent nodes • Actual value of the node
  • 10.  Graph() creates a new, empty graph.  Transformers:  addNode() adds an instance of Vertex to the graph.  addEdge(Node1, Node2) adds a new, directed edge to the graph that connects two vertices.  deleteNode(Node) removes a node and any edges between this node and other nodes.  deleteEdge(Node1, Node2) delete the edge between two given nodes: Node1 & Node 2. Adjacency List Methods
  • 11.  Observers:  getVertices() returns the list of all vertices in the graph.  isEmpty() determines whether the graph is empty.  isLink(Node1, Node2) returns true if edge(Node1, Node2) is present in the graph, false otherwise. Bonus method/s: findPath(Node1, Node2) //pre: Node1 and Node2 are existing in the graph //post: returns the list of nodes on a path from Node1 to Node2. Adjacency List Methods
  • 12. Pros and Cons of ADT:  Advantages:  Easy to retrieve all the adjacent nodes of a given node(just traverse the list associated with the node)  Easy to check whether a node has edges starting from it  Less memory space is needed.  Limitation:  More complex operation for checking whether there is an edge between two given nodes. Pros and Cons of ADT
  • 13. Graph Traversal Algorithms Depth First Search  Puts unvisited nodes in a STACK. Breadth First Search  Puts unvisited nodes in a QUEUE. Traversal Algorithms
  • 14. Applications of ADT:  The applications for graphs are many and varied. They can be used to analyze electrical circuits, develop project schedules, find shortest routes, analyze social relationships, and construct models for the analysis and solution of many other problems. Applications of ADT