מבנה המחשב – מבוא למחשבים ספרתיים Foundations of Combinational Circuits תרגול מספר 3.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Graph Algorithms
Advertisements

What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Single Source Shortest Paths
Lecture 7 March 1, 11 discuss HW 2, Problem 3
Cpt S 223 – Advanced Data Structures Graph Algorithms: Introduction
Chapter 9: Graphs Topological Sort
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Tirgul 7 Review of graphs Graph algorithms: –DFS –Properties of DFS –Topological sort.
Theory of Computing Lecture 6 MAS 714 Hartmut Klauck.
Lecture 16: DFS, DAG, and Strongly Connected Components Shang-Hua Teng.
CSE 2331/5331 Topic 11: Basic Graph Alg. Representations Undirected graph Directed graph Topological sort.
1 Graphs: Traversal Searching/Traversing a graph = visiting the vertices of a graph by following the edges in a systematic way Example: Given a highway.
Tirgul 11 DFS Properties of DFS Topological sort.
Graph & BFS.
Topics: 1. Finding a cycle in a graph 2. Propagation delay - example 3. Trees - properties מבנה המחשב - אביב 2004 תרגול 3#
Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#
1 Data Structures DFS, Topological Sort Dana Shapira.
Connected Components, Directed Graphs, Topological Sort COMP171.
Graph COMP171 Fall Graph / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D E A C F B Vertex Edge.
Graph & BFS Lecture 22 COMP171 Fall Graph & BFS / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D.
COMP171 Depth-First Search.
CSE 373: Data Structures and Algorithms Lecture 18: Graphs II 1.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
Alyce Brady CS 510: Computer Algorithms Depth-First Graph Traversal Algorithm.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Depth-First Search Idea: Keep going forward as long as there are unseen nodes to be visited. Backtrack when stuck. v G G G G is completely traversed.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Spring 2015 Lecture 10: Elementary Graph Algorithms
CSC 331: Algorithm Analysis Decompositions of Graphs.
Chapter 2 Graph Algorithms.
Discussion #32 1/13 Discussion #32 Properties and Applications of Depth-First Search Trees.
Graphs and Graph Algorithms Fundamentals, Terminology, Traversal, Algorithms SoftUni Team Technical Trainers Software University
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
CS 61B Data Structures and Programming Methodology Aug 5, 2008 David Sun.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Eulerian Paths and Cycles. What is a Eulerian Path Given an graph. Find a path which uses every edge exactly once. This path is called an Eulerian Path.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Section 13  Questions  Graphs. Graphs  A graph representation: –Adjacency matrix. Pros:? Cons:? –Neighbor lists. Pros:? Cons:?
Topological Sort: Definition
DIRECTED ACYCLIC GRAPHS AND TOPOLOGICAL SORT CS16: Introduction to Data Structures & Algorithms Tuesday, March 10,
Properties and Applications of Depth-First Search Trees and Forests
Graph. Graph Usage I want to visit all the known famous places starting from Seoul ending in Seoul Knowledge: distances, costs Find the optimal(distance.
1 Chapter 22: Elementary Graph Algorithms III. 2 About this lecture Topological Sort.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Graphs + Shortest Paths David Kauchak cs302 Spring 2013.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
SSSP in DAGs (directed acyclic graphs). DFS (depth first search) DFS(vertex v) { v.visited = TRUE; for each w adjacent to v do if(!w.visited) then dfs(w);
Graph Theory Def: A graph is a set of vertices and edges G={V,E} Ex. V = {a,b,c,d,e} E = {ab,bd,ad,ed,ce,cd} Note: above is a purely mathematical definition.
Week 11 - Wednesday.  What did we talk about last time?  Exam 2  And before that:  Graph representations  Depth first search.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Data Structures and Algorithm Analysis Lecture 5
Breadth-First Search (BFS)
Topological Sort In this topic, we will discuss: Motivations
Depth-First Search.
More Graph Algorithms.
Graph.
"Learning how to learn is life's most important skill. " - Tony Buzan
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Connected Components, Directed Graphs, Topological Sort
CSE 373 Graphs 4: Topological Sort reading: Weiss Ch. 9
CSE 417: Algorithms and Computational Complexity
Presentation transcript:

מבנה המחשב – מבוא למחשבים ספרתיים Foundations of Combinational Circuits תרגול מספר 3

Checking a Circuit Mapping the circuit into a directed graph G(V,E).  Each gate is a vertex  Each output terminal defines a net  Each net is transformed into edges from the output terminal to each of the input terminals. OR AND NOT XOROUT IN Single net

Graph Representation by List of Neighbors

Graph Representation by Matrix v v v

Checking a Circuit If a terminal has two incoming edges, then it is fed by two nets, which is illegal. In that case we stop and return FALSE. OR AND NOT XOROUT IN Two inputs to one terminal !

Testing for Circles In order to test for circles we need to run a Depth-First-Search (DFS) algorithm on the graph, and check for any backwards edges during the execution of the algorithm.

DFS Example Stack

DFS Stack = Currently in the stack

DFS Stack

DFS Stack

DFS Stack Backwards Edge This graph has a cycle!

Elements of the Proof The algorithm terminates regardless of the structure of the input graph. If there is a cycle in the graph, the algorithm will find it (return FALSE). If there is no cycle in the graph, the algorithm will return TRUE.

The Algorithm Terminates The algorithm passes through every vertex only once, therefore it will always terminate after visiting all of the vertices regardless of the edges.

The Proof Assume there is a cycle in the graph. At some point a first vertex that belongs to the cycle will be reached. All other vertices of the cycle have not been reached yet. Before that first vertex is popped out of the stack, the DFS procedure guarantees that an edge closing the cycle and entering that vertex will be tested. It is a backwards edge.

The Proof Immediate, but nevertheless: Assume there are no cycles in the graph. Backwards edges cannot exist since they require a path from a successor to a predecessor, which means there is a cycle.

Topological Sort Works only on Directed Acyclic Graphs (DAG). The Algorithm: –Form a set of all independent vertices - those that have no incoming edges. There must be at least one! –While the set is empty: Pick any vertex v from the set. If any of its successors have no other predecessors – add them to the set of independent vertices. Erase all of the edges originating at v.

Topological Sort Example OR AND NOT XOROUT IN = Independent Vertex

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN OR

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN ORAND

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN ORANDNOT

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN ORANDNOTXOR

Topological Sort Example OR AND NOT XOROUT IN The Topological Sort: IN ORANDNOTXOROUT

Testing for Cycles during Topological Sort OR AND NOT XOROUT IN There are nodes left, but none are independent Cycle!

Propagation Delay There is always at least one “critical path”. What is the propagation delay of a circuit that is not acyclic?

Finding the Propagation Delay Now, using the fact that it is an acyclic graph, we go through the topological order from start to beginning, each time updating the “inputs ready” time of the successors. The total propagation delay is the maximal “inputs ready” time (assuming that we used output nodes).

Finding the Maximum Delay 00ORANDNOTXOROUT

A circuit with 2 n/2 paths 2 options n/2 stages with 2 options each, resulting in 2 n/2 paths. How are we computing the delay of an exponential number of circuits in linear time? Let’s go to the previous slide.

A circuit with 2 n paths …cannot be built! Why? A combinational circuit is a DAG, therefore we cannot reorder the gates to create different paths. Our only option is to include or exclude gates to create different paths. But, having n gates, we only have 2 n such paths. Each gate can be included or excluded, therefore 2 n. We cannot build this circuit since we will require an unbounded in-degree of the gates.

XOR is Associative – part I Definition 1 st Expanded definition De Morgan Distributive Complement Distributive

XOR is Associative – part 2 Definition 2 nd Expanded definition De Morgan Distributive Complement Distributive

THE END