Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

No Downloads

Total views

1,696

On SlideShare

0

From Embeds

0

Number of Embeds

4

Shares

0

Downloads

33

Comments

0

Likes

1

No embeds

No notes for slide

- 1. GRAPHS Adjacency Lists Reporters: Group 10
- 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.)
- 4. Graph Illustration Path from V3 to V1?
- 5. ADJACENCY LIST
- 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
- 8. Adjacency List Illustration
- 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
- 15. Applications of ADT Con’t

No public clipboards found for this slide

Be the first to comment